Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include <Ticker.h>
  2.  
  3. #define SIGNAL_PIN D2
  4.  
  5. Ticker flipper;
  6.  
  7. void setup()
  8. {
  9. Serial.begin(9600);
  10. pinMode(SIGNAL_PIN, INPUT);
  11. digitalWrite (SIGNAL_PIN, LOW);
  12.  
  13.  
  14. }
  15.  
  16. void flip(){
  17. Serial.println("From callback");
  18. digitalWrite (SIGNAL_PIN, HIGH);
  19. }
  20.  
  21.  
  22. void loop() {
  23. if(digitalRead(SIGNAL_PIN)==HIGH) {
  24. Serial.println("Movement detected.");
  25. flipper.attach(1, flip);
  26. } else {
  27. Serial.println("Did not detect movement.");
  28. flipper.detach();
  29. }
  30. delay(1000);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement