mirror of
https://codeberg.org/eel4746_piano/avr_piano.git
synced 2024-11-22 09:10:30 -05:00
add untested pin change interrupts for note buttons
This commit is contained in:
parent
f5713538fe
commit
3808c19de4
43
notes.c
43
notes.c
@ -1,6 +1,7 @@
|
||||
/*
|
||||
* EEL4746C - AVR Piano - Speaker Section
|
||||
* speaker is connected to PD2 and ground, PD3-7
|
||||
* speaker is connected to PD2 and ground
|
||||
* buttons are connceted to PB0-5, PC0-5, PD3-7
|
||||
* the LCD Arduino UNO is connected to TX/RX (PD0/1)
|
||||
*/
|
||||
|
||||
@ -37,8 +38,8 @@ unsigned short freqs[] = {
|
||||
FREQ(7000),
|
||||
FREQ(8000),
|
||||
};
|
||||
unsigned char note = 8;
|
||||
unsigned char buttonpressed = 1;
|
||||
unsigned char note = 0;
|
||||
unsigned char buttonpressed = 0;
|
||||
|
||||
int
|
||||
main(void)
|
||||
@ -79,15 +80,51 @@ main(void)
|
||||
|
||||
ISR (PCINT0_vect)
|
||||
{
|
||||
// check if any button on any port is pressed
|
||||
if (PINB | PINC | PIND)
|
||||
buttonpressed = 1;
|
||||
else
|
||||
buttonpressed = 0;
|
||||
|
||||
// check if any button in the whole port is pressed
|
||||
for (unsigned char i = 0; i <= 5; i++) {
|
||||
if (PINB & (1 << i)) {
|
||||
note = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ISR (PCINT1_vect)
|
||||
{
|
||||
// check if any button on any port is pressed
|
||||
if (PINB | PINC | PIND)
|
||||
buttonpressed = 1;
|
||||
else
|
||||
buttonpressed = 0;
|
||||
|
||||
// check if any button in the whole port is pressed
|
||||
for (unsigned char i = 0; i <= 5; i++) {
|
||||
if (PINC & (1 << i)) {
|
||||
note = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ISR (PCINT2_vect)
|
||||
{
|
||||
// check if any button on any port is pressed
|
||||
if (PINB | PINC | PIND)
|
||||
buttonpressed = 1;
|
||||
else
|
||||
buttonpressed = 0;
|
||||
|
||||
// check if any button in the whole port is pressed
|
||||
for (unsigned char i = 3; i <= 7; i++) {
|
||||
if (PIND & (1 << i)) {
|
||||
note = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user