working test firmware (yes, setting the pullups is a good idea)
This commit is contained in:
parent
61c84c52aa
commit
85f143f54c
|
@ -79,6 +79,7 @@ static void set_motor(int val){
|
||||||
|
|
||||||
static void init_switch(void){
|
static void init_switch(void){
|
||||||
DDRD &= ~( (1 << PORTD1) | (1<<PORTD0));
|
DDRD &= ~( (1 << PORTD1) | (1<<PORTD0));
|
||||||
|
PORTD |= (1 << PORTD1) | (1<<PORTD0); //Pullups FTW
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,21 +176,26 @@ int main(void)
|
||||||
case 3:
|
case 3:
|
||||||
mode_beeptest();
|
mode_beeptest();
|
||||||
break;
|
break;
|
||||||
case 4: break;
|
|
||||||
default: //mode=0;
|
default: //mode=0;
|
||||||
blinkrattlebeep();
|
blinkrattlebeep();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//check switches and change mode
|
//check switches and change mode
|
||||||
switch( PIND & 0b00000011){
|
switch( PIND & 0b00000011){
|
||||||
case 2: //left switch pressed
|
case 0b00000010: //left switch pressed
|
||||||
mode = (mode+1) % 4;
|
mode--;
|
||||||
|
if (mode > 3) mode =3;
|
||||||
flashleds(LED_L);
|
flashleds(LED_L);
|
||||||
break;
|
break;
|
||||||
case 1: //right switch pressed
|
case 0b00000001: //right switch pressed
|
||||||
mode = (mode-1) % 4;
|
mode++;
|
||||||
|
if (mode > 3) mode = 0;
|
||||||
flashleds(LED_R);
|
flashleds(LED_R);
|
||||||
break;
|
break;
|
||||||
|
case 0b00000000: //both switches pressed
|
||||||
|
flashleds(LED_R|LED_L);
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user