Advertisement
RuiViana

Teste Interrupt

Aug 9th, 2015
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1.  
  2. #define botao 2
  3. #define LED 13
  4. byte cnt = 0;
  5. byte cnt2 = 0;
  6. char LED_status;
  7. //-------------------------
  8. void setup()
  9. {
  10. pinMode(botao, INPUT);
  11. pinMode(LED, OUTPUT);
  12. attachInterrupt(0, PressDn, FALLING);
  13. }
  14. //--------------------------
  15. void PressDn()
  16. {
  17. detachInterrupt(0);
  18. // noInterrupts();
  19. cnt2++;
  20. cnt = 0;
  21. LED_status = !LED_status;
  22. digitalWrite(LED, LED_status);
  23. }
  24. //-------------------------
  25. void loop()
  26. {
  27. while(cnt == 0)
  28. {
  29. // interrupts(); // 2a opção
  30. attachInterrupt(0, PressDn, FALLING);
  31. cnt = 1;
  32. while(cnt2 >= 3)
  33. {
  34. ;
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement