Add the following snippet to your HTML:
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); } }
Comments