Advertisement
shamzed

day 4 old

Mar 21st, 2023
740
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int readPin = A5;
  2. int lightPin = 7;
  3. int lightState = 0;
  4. int dt = 100;
  5. int buttonPinNew;
  6. int buttonPinOld = 1;
  7. void setup() {
  8.   // put your setup code here, to run once:
  9.   Serial.begin(9600);
  10.   pinMode(readPin, INPUT);
  11.   pinMode(lightPin, OUTPUT);
  12. }
  13.  
  14. void loop() {
  15.   // put your main code here, to run repeatedly:
  16.   buttonPinNew = digitalRead(readPin);
  17.   if (buttonPinOld == 0 && buttonPinNew == 1)
  18.   {
  19.     if (lightState == 0)
  20.     {
  21.       while(1)
  22.       {
  23.           digitalWrite(lightPin, HIGH);
  24.           delay(1000);
  25.           digitalWrite(lightPin, LOW);
  26.           delay(1000);
  27.           //lightState = 1;
  28.           buttonPinNew = digitalRead(readPin);
  29.           if (buttonPinOld == 0 && buttonPinNew == 1)
  30.           buttonPinOld = buttonPinNew;
  31.       }
  32.     }
  33.     else
  34.     {
  35.       digitalWrite(lightPin, LOW);
  36.       lightState = 0;
  37.     }
  38.   }
  39.   buttonPinOld = buttonPinNew;
  40.   //delay(dt);
  41.  
  42.  
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement