Answered step by step
Verified Expert Solution
Link Copied!

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?

image text in transcribed

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 loop

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

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions