Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int buttonPin = 8;
- const int ledPin = 12;
- int state = 0;
- void setup() {
- Serial.begin(9600);
- pinMode(ledPin, OUTPUT);
- pinMode(buttonPin, INPUT);
- }
- void loop() {
- if ( digitalRead(buttonPin) == HIGH && state == 0 )
- {
- digitalWrite(ledPin, HIGH);
- state = 1;
- }
- if( digitalRead(buttonPin) == HIGH && state == 1 )
- {
- digitalWrite(ledPin, LOW);
- state = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment