Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!