Advertisement
Guest User

Untitled

a guest
Apr 7th, 2023
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1.  
  2.  
  3. const int LED_PIN = 13;
  4. const int INTERRUPT_PIN = 2;
  5. int cas = 0;
  6. //unsigned long previousMillis = 0UL;
  7. //unsigned long interval = 1000UL;
  8.  
  9. void setup() {
  10. // put your setup code here, to run once:
  11. pinMode(LED_PIN, OUTPUT);
  12. pinMode(INTERRUPT_PIN, INPUT_PULLUP);
  13. attachInterrupt(digitalPinToInterrupt(INTERRUPT_PIN), resetcasovac, FALLING);
  14. Serial.begin(9600);
  15. return run();
  16. }
  17.  
  18. void loop() {
  19. // put your main code here, to run repeatedly
  20.  
  21. }
  22.  
  23. void run(){
  24.  
  25. for(cas; cas < 30;cas++){
  26. delay(1000);
  27. //unsigned long currentMillis = millis();
  28.  
  29. //if(currentMillis - previousMillis > interval)
  30. //{
  31. //cas++;
  32. //previousMillis = currentMillis;
  33. Serial.println(cas);
  34. //}
  35. if(cas>20){
  36. digitalWrite(LED_PIN, HIGH);
  37. }
  38.  
  39. }
  40. Serial.println("Tlacitko nezmacknuto.");
  41.  
  42. }
  43.  
  44. void resetcasovac(){
  45. cas = 0;
  46. digitalWrite(LED_PIN, LOW);
  47. Serial.println("Tlacitko zmacknuto.");
  48.  
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement