Guest User

Untitled

a guest
Jul 28th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. int pushes = 0;
  2. int frequency = 10;
  3. int button = LOW;
  4. int buttonPin = D0;
  5. int ledPin = D7;
  6.  
  7. void setup() {
  8. pinMode(buttonPin,INPUT);
  9. pinMode(ledPin,OUTPUT);
  10. }
  11.  
  12.  
  13. void loop() {
  14.  
  15. digitalWrite(ledPin, HIGH); // Turn LED on - for feedback
  16. button = digitalRead(buttonPin); // Read if button is pushed
  17.  
  18. if (button == HIGH){ // if the button has been pushed
  19. pushes++; // Add +1 to the number of pushes
  20. digitalWrite(ledPin, LOW); // Turn the LED off, to indicate button works
  21.  
  22. if (pushes % frequency == 0){ // Every 10, 20, 30, 40 etc
  23. Spark.publish("publish",String(pushes)); // publish the number of pushes to IFTTT
  24. }
  25.  
  26. delay(400); // delay before turning LED back on (and prevent spam)
  27. button = LOW;
  28. }
  29. delay(50);
  30. }
Add Comment
Please, Sign In to add comment