Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int pushes = 0;
- int frequency = 10;
- int button = LOW;
- int buttonPin = D0;
- int ledPin = D7;
- void setup() {
- pinMode(buttonPin,INPUT);
- pinMode(ledPin,OUTPUT);
- }
- void loop() {
- digitalWrite(ledPin, HIGH); // Turn LED on - for feedback
- button = digitalRead(buttonPin); // Read if button is pushed
- if (button == HIGH){ // if the button has been pushed
- pushes++; // Add +1 to the number of pushes
- digitalWrite(ledPin, LOW); // Turn the LED off, to indicate button works
- if (pushes % frequency == 0){ // Every 10, 20, 30, 40 etc
- Spark.publish("publish",String(pushes)); // publish the number of pushes to IFTTT
- }
- delay(400); // delay before turning LED back on (and prevent spam)
- button = LOW;
- }
- delay(50);
- }
Add Comment
Please, Sign In to add comment