?

Generation

generate functionSat, 18 Feb 2023

Generate a button that you can press to get points.

#include "Particle.h" #include "Adafruit_SSD1306.h" #include "Adafruit_GFX.h" int button = D6; const int buttonPin = D7; const int ledPin = D4; int counter = 0; void setup() { pinMode(buttonPin, INPUT); pinMode(ledPin, OUTPUT); Particle.function("score",score); Serial.begin(115200); } void loop() { // put your main code here, to run repeatedly: } int score(String args){ int buttonState = digitalRead(buttonPin); int score = 0; if (buttonState == LOW) { digitalWrite(ledPin, HIGH); score = score + 1; return score; } else { digitalWrite(ledPin, LOW); } }

Questions about programming?Chat with your personal AI assistant