Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with arduino code in the area of if and else statement for a switch that will control when a LED will go

I need help with arduino code in the area of if and else statement for a switch that will control when a LED will go on and off. When the LED go on the phrase "LED is ON" will appear on the serial monitor, and when LED is off it will read that "LED is OFF'. The current if condition "if(outPin=HIGH and current=HIGH) { Serial.println("switch on LED ON 5V");"

will read on and off.

here is the full code:

//switch current= digitalRead(inPin);

if (current== HIGH && millis() - time > debounce) { // current reading read ON if (state == HIGH) // if current state is ON state = LOW; // flipping switch will turn it off else state = HIGH; // if the current reading is off then turn switch on. time = millis(); } digitalWrite(outPin, state); //current==previous;

if(outPin=HIGH and current=HIGH) { Serial.println("switch on LED ON 5V"); } else { Serial.println("switch off LED OFF 0V");}

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_2

Step: 3

blur-text-image_3

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

More Books

Students also viewed these Databases questions

Question

Compare and contrast a network-based IPS, and a host-based IPS.

Answered: 1 week ago

Question

2. What are your challenges in the creative process?

Answered: 1 week ago