Advertisement
Guest User

Untitled

a guest
Apr 8th, 2020
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. int cnt = 0;
  2. int pinInput = 6;
  3. int pinOutput = 8;
  4. bool posledno = false;
  5.  
  6. void setup() {
  7.   // put your setup code here, to run once:
  8.   pinMode(pinInput, INPUT);
  9.   pinMode(pinOutput, OUTPUT);
  10. }
  11.  
  12. void loop() {
  13.   // put your main code here, to run repeatedly:
  14.   bool sea = digitalRead(pinInput);
  15.   if (sea != posledno) {
  16.     if (sea == false) cnt++;
  17.  
  18.     posledno = sea;
  19.   }
  20.  
  21.   if (cnt == 20) {
  22.     digitalWrite(pinOutput, HIGH);
  23.     delay(500);
  24.     digitalWrite(pinOutput, LOW);
  25.     cnt = 0;
  26.   }
  27.  
  28.   delay(2);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement