Question: How would you make your codes to have the same results for the switch combinations listed in the table: The pins 2, 3, and 4

How would you make your codes to have the same results for the switch combinations listed in the table:

The pins 2, 3, and 4 of Arduino UNO are assigned as Green, Blue, Red LED output,

respectively.The pins 8 and 9 of Arduino UNO are assigned as Buttons A and B, respectively. All input are set up as pull-up condition.

How would you make your codes to have the same results for

By using the given codes below

:the switch combinations listed in the table: The pins 2, 3, and

4 of Arduino UNO are assigned as Green, Blue, Red LED output,

| / Green LED off Red SW not push not push Push Push Red LED off Yellow SW not push Push not push Push Blue LED off off off on on off off on off off // variables int GREEN = 2; // Pin 2 is Green LED int YELLOW = 3; // Pin 3 is Yellow LED int RED = 4; // Pin 4 is Red LED int DELAY_GREEN = 5000; int DELAY_YELLOW = 2000; int DELAY_RED = 5000; // basic functions void setup() void green_light() // Green light control user define function pinMode (GREEN, OUTPUT); pinMode (YELLOW, OUTPUT); pinMode (RED, OUTPUT); digitalWrite(GREEN, HIGH); digitalWrite (YELLOW, LOW); digitalWrite(RED, LOW); void loop() // Call Green light fuction void yellow_light() // Yello light control user define fucntion // Call Yellow light fuction green light(); delay (DELAY_GREEN); yellow_light(); delay (DELAY_YELLOW); red light (); delay (DELAY_RED); digitalWrite(GREEN, LOW); digitalWrite (YELLOW, HIGH); digitalWrite (RED, LOW); 1/ Call Red light fuction void red light() // Red light control user define fucntion digitalWrite(GREEN, LOW); digitalWrite(YELLOW, LOW); digitalWrite (RED, HIGH); int LEDPIN = 5; int BUTTON_A_PIN = 8; int BUTTON_B_PIN = 9; // Pin 5 is for LED // Pin 8 is for push switch A // Pin 9 is for push switch B byte Leds = 0; void setup() pinMode(LEDPIN, OUTPUT); pinMode(BUTTON_A_PIN, INPUT_PULLUP); pinMode(BUTTON_B_PIN, INPUT_PULLUP); // Pin 5 is output // Pin 8 is for input and is pull-up // Pin 9 is for input and is pull-up void loop(). if (digitalRead (BUTTON A PIN) == LOW) // Switch Ais pushed? digitalWrite(LEDPIN, HIGH); // If switch A is pushed, LED is on. if (digitalRead(BUTTON_B_PIN) == LOW) // Switch B is pushed? digitalWrite(LEDPIN, LOW); // If switch B is pushed, LED is off

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!