Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Metro.h>
- int button = 2;
- int led = 13;
- int points = 0;
- int pointState = 3;
- boolean ledState = LOW;
- Metro ledButton = Metro(0);
- void setup()
- {
- Serial.begin(9600);
- pinMode (led, OUTPUT);
- pinMode (button, INPUT);
- }
- void loop()
- {
- boolean buttonState = digitalRead(button);
- if (ledButton.check() == 1)
- {
- if (ledState == LOW)
- {
- ledState = HIGH;
- if (pointState == HIGH){
- points++;
- pointState = 3;
- }
- ledButton.interval(500);
- }
- else
- {
- ledState = LOW;
- if (pointState == LOW){
- points--;
- pointState = 3;
- }
- Serial.println(points);
- }
- }
- if (buttonState == HIGH && ledState == HIGH)
- pointState = HIGH;
- if (buttonState == HIGH && ledState == LOW)
- pointState = LOW;
- digitalWrite (led,ledState);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement