Advertisement
elektronek

Richard Singer - tlačítko ON/OFF

Feb 1st, 2023
916
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. uint8_t stav=0;
  2. uint8_t tlStav=0;
  3.  
  4. void setup() {
  5.   pinMode(12, INPUT_PULLUP);
  6.   pinMode(13, OUTPUT);
  7. }
  8.  
  9. void loop() {
  10.   if (digitalRead(12)==0 && tlStav==0)
  11.   {
  12.     if (!stav) stav=1; else stav=0; // zmen stav
  13.     tlStav=1;  // nastav priznak stisknuti tl
  14.   }
  15.  
  16.   if (digitalRead(12)==1) tlStav=0; // smaz priznak stisknuti tl
  17.  
  18.   if (stav==1)
  19.     digitalWrite(13, HIGH);
  20.   else
  21.     digitalWrite(13, LOW);
  22. }
Tags: Arduino
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement