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