Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int readPin = A5;
- int lightPin = 7;
- int lightState = 0;
- int dt = 100;
- int buttonPinNew;
- int buttonPinOld = 1;
- void setup() {
- // put your setup code here, to run once:
- Serial.begin(9600);
- pinMode(readPin, INPUT);
- pinMode(lightPin, OUTPUT);
- }
- void loop() {
- // put your main code here, to run repeatedly:
- buttonPinNew = digitalRead(readPin);
- if (buttonPinOld == 0 && buttonPinNew == 1)
- {
- if (lightState == 0)
- {
- while(1)
- {
- digitalWrite(lightPin, HIGH);
- delay(1000);
- digitalWrite(lightPin, LOW);
- delay(1000);
- //lightState = 1;
- buttonPinNew = digitalRead(readPin);
- if (buttonPinOld == 0 && buttonPinNew == 1)
- buttonPinOld = buttonPinNew;
- }
- }
- else
- {
- digitalWrite(lightPin, LOW);
- lightState = 0;
- }
- }
- buttonPinOld = buttonPinNew;
- //delay(dt);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement