Last active
March 11, 2020 19:08
-
-
Save mkhan45/28b4f628469704bcaa4270a7beb18c17 to your computer and use it in GitHub Desktop.
game for AT club
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Game { | |
BlinkGame | |
}; | |
static Game game; | |
const int button1 = 3; | |
const int button2 = 4; | |
const int button3 = 5; | |
const int greenled = 6; | |
const int redled = 7; | |
const int rgbled1 = 8; | |
const int rgbled2 = 9; | |
const int rgbled3 = 10; | |
static int buttonState1 = digitalRead(button1); | |
static int buttonState2 = digitalRead(button2); | |
static int buttonState3 = digitalRead(button3); | |
long randomint = 0; | |
static int tick = 0; | |
void setup() { | |
// put your setup code here, to run once: | |
Serial.begin(9600); | |
game = BlinkGame; | |
pinMode(greenled, OUTPUT); | |
pinMode(redled, OUTPUT); | |
pinMode(rgbled2, OUTPUT); | |
pinMode(button1, INPUT); | |
pinMode(button2, INPUT); | |
} | |
void loop() { | |
tick += 1; | |
buttonState1 = digitalRead(button1); | |
buttonState2 = digitalRead(button2); | |
buttonState3 = digitalRead(button3); | |
// put your main code here, to run repeatedly: | |
switch (game) { | |
case BlinkGame: | |
blink_game(); | |
break; | |
default: | |
break; | |
} | |
} | |
void blink_game() { | |
Serial.println(buttonState1); | |
if (buttonState1 == HIGH) { | |
digitalWrite(LED_BUILTIN, HIGH); | |
} else { | |
digitalWrite(LED_BUILTIN, LOW); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment