bool button_state, last_state = 0;
int cnt = 13, last_cnt;
bool random_button_state, random_last_state = 0;
void setup() {
for(int i = 4; i < 14; i++){
pinMode(i, OUTPUT);
}
pinMode(2, INPUT);
pinMode(3, INPUT);
Serial.begin(9600);
randomSeed(analogRead(0));
}
void loop() {
button_state = digitalRead(3);
random_button_state = digitalRead(2);
if(button_state == 1 and last_state == 0){
last_state = button_state;
last_cnt = cnt;
cnt--;
}
if(button_state == 0)last_state = button_state;
if(cnt == 3) cnt = 13;
if(random_button_state == 1 and random_last_state == 0){
random_last_state = random_button_state;
last_cnt = cnt;
cnt = random(4,14);
}
if(random_button_state == 0)random_last_state = random_button_state;
Serial.println(last_cnt);
digitalWrite(cnt, HIGH);
if(cnt != last_cnt) digitalWrite(last_cnt, LOW);
}