Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PROJECT QUESTION: How could you make a larger, or more complex interface for your interstellar adventures with LEDs and switches? int switchState = 0; void
PROJECT QUESTION: How could you make a larger, or more complex interface for your interstellar adventures with LEDs and switches?
int switchState = 0; void setup() { pinMode (3, OUTPUT); pinMode(4, OUTPUT); pinMode (5, OUTPUT); pinMode (2, OUTPUT); } void loop() { switchState = digitalRead (2); if (switchState LOW){ // 'if' the button is NOT pressed digitalWrite(3, HIGH); // green LED digitalWrite(4, LOW); // red LED digitalWrite(5, LOW); // red LED } else { // 'else' the button IS pressed digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite (5, HIGH); \ delay(250); // wait for a quarter second // toggle the LEDs digitalWrite(4, HIGH); digitalWrite(5, LOW); delay (250); // wait for a quarter second } } // go back to the beginning of the loop int switchState = 0; void setup() { pinMode (3, OUTPUT); pinMode(4, OUTPUT); pinMode (5, OUTPUT); pinMode (2, OUTPUT); } void loop() { switchState = digitalRead (2); if (switchState LOW){ // 'if' the button is NOT pressed digitalWrite(3, HIGH); // green LED digitalWrite(4, LOW); // red LED digitalWrite(5, LOW); // red LED } else { // 'else' the button IS pressed digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite (5, HIGH); \ delay(250); // wait for a quarter second // toggle the LEDs digitalWrite(4, HIGH); digitalWrite(5, LOW); delay (250); // wait for a quarter second } } // go back to the beginning of the loopStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started