Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Level 1: Run the following code to make sure your button works. int blueLedPin = 13 ; //The blue LED is connected pin 13 of

Level 1: Run the following code to make sure your button works.

int blueLedPin = 13 ; //The blue LED is connected pin 13 of the Arduino.

int button1Pin = 2; //The SW1 button is connect to pin 2 of the Arduino.

void setup() { //The Setup function runs once

pinMode(blueLedPin, OUTPUT); //Setup blue LED pin as an output pin.

pinMode(button1Pin, INPUT); //Setup button1 pin as an input pin.

}

void loop() { //The loop function runs forever.

if (digitalRead(button1Pin) == HIGH) { //Check to see if button1 is pressed.

digitalWrite(blueLedPin, HIGH);//Turn on the blue LED.

} else { digitalWrite(blueLedPin, LOW); //Turn off the blue LED.

}

}

Level 2: Add a second button that will control a red led.

Level 3: Using the RGB LED have button 1 turn on the RGB light, cycling through the three colours in repetition(ex:Red Green Blue Red ect.) with a 500 msec delay. Then use the second button to shut off the lights. The light should shut off immediately after the current colour and not continue to cycle to other colours after the button is pressed. There can be a 500 ms button press to shut off lights.

Level 4: Add a green and red LED to the circuit with the RGB LED. Include 2 buttons. The first button will toggle between the red and green LED. If the green LED is on when you hit button 2 the RGB will start cycling through the 3 colours. If the 2nd button is pressed the RGB lights stop. If the 1st button is pressed the RGB stops AND the green LED turn off and the red LED turns ON. If the red LED is on, nothing happens when you press the 2nd button. Here's the sequence used to test your code

ACTION Green/Red LED RGB LED

Start Red OFF

Button #1 Pressed Green OFF

Button #1 Pressed Red OFF

Button #2 Pressed Red OFF

Button #1 Pressed Green OFF

Button #2 Pressed Green ON (cycling)

Button #2 Pressed Green OFF

Button #2 Pressed Green ON (cycling)

Button #1 Pressed Red OFF

End testing

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions

Question

what is the most common cause of preterm birth in twin pregnancies?

Answered: 1 week ago

Question

Which diagnostic test is most commonly used to confirm PROM?

Answered: 1 week ago

Question

What is the hallmark clinical feature of a molar pregnancy?

Answered: 1 week ago

Question

3. Discuss the process of behavior modeling training.

Answered: 1 week ago