Add the following snippet to your HTML:<iframe frameborder='0' height='385' scrolling='no' src='https://www.hackster.io/laurenkoi/arduino-project-2-92796e/embed' width='350'></iframe>
Learning to control electricity with lights and switches. This project is my first programming time for Arduino.
Read up about this project on
Learning about inputs. This was the first time that I wrote code for the arduino.
int switchState = 0; void setup(){ pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(2, INPUT); } void loop() { switchState=digitalRead(2); if (switchState == LOW) { digitalWrite(3, HIGH); digitalWrite(4, LOW); digitalWrite(5, LOW); } else { digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, HIGH); delay(250); digitalWrite(4, HIGH); digitalWrite(5, LOW); delay(250); } }
Please log in or sign up to comment.
Comments
Please log in or sign up to comment.