Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <TM1637Display.h>
- const int CLK = 6;
- const int DIO = 7;
- const int buttonPin1 = 2;
- const int buttonPin2 = 3;
- const int buttonPin3 = 4;
- const int resetPin = 5;
- int buttonState1 = 0;
- int buttonState2 = 0;
- int buttonState3 = 0;
- int resetState = 0;
- TM1637Display display(CLK, DIO);
- int score = 0;
- void setup() {
- // put your setup code here, to run once:
- pinMode(buttonPin1, INPUT_PULLUP); // use internal pullup
- pinMode(buttonPin2, INPUT_PULLUP);
- pinMode(buttonPin3, INPUT_PULLUP);
- pinMode(resetPin, INPUT_PULLUP);
- display.setBrightness(0x0a);
- Serial.begin(9600);
- }
- void loop() {
- buttonState1 = digitalRead(buttonPin1);
- buttonState2 = digitalRead(buttonPin2);
- buttonState3 = digitalRead(buttonPin3);
- resetState = digitalRead(resetPin);
- if (buttonState1 == LOW) {
- score += 1;
- Serial.println(score);
- display.showNumberDec(score);
- delay(200);
- }
- if (buttonState2 == LOW) {
- score += 2;
- Serial.println(score);
- display.showNumberDec(score);
- delay(200);
- }
- if (buttonState3 == LOW) {
- score += 3;
- display.showNumberDec(score);
- delay(200);
- }
- if (resetState == LOW) {
- score = 0;
- Serial.println(score);
- display.showNumberDec(score);
- delay(200);
- }
- display.showNumberDec(score);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement