Rewrite button interupt on multiple pins to one pin
for project, i'm trying rewrite code read button presses on several pins code read button presses on 1 analog pin.
this original code, reads few simple push buttons:
now, want convert code can used lcd keypad shield. these buttons wired resistors, , can read analog pin, see example in link.
i've been thinking this, i'm inexperienced programmer, haven't been able figure out. realise may not trivial, maybe can me little on way this?
this original code, reads few simple push buttons:
code: [select]
// buttons interrupt
// interrupt handler button presses
isr(pcint1_vect)
{
unsigned long m = millis();
currentbuttons[lbutton] = digitalread(lbuttonpin);
currentbuttons[mbutton] = digitalread(mbuttonpin);
currentbuttons[rbutton] = digitalread(rbuttonpin);
(int loop = 0; loop < numbuttons; loop++)
{
// button down press
if ((previousbuttons[loop] == up) && (currentbuttons[loop] == down))
{
lastbuttontimedown[loop] = m;
}
// button release press
else if ((previousbuttons[loop] == down) && (currentbuttons[loop] == up))
{
lastbuttontimedown[loop] = 0;
}
previousbuttons[loop] = currentbuttons[loop];
}
}
now, want convert code can used lcd keypad shield. these buttons wired resistors, , can read analog pin, see example in link.
i've been thinking this, i'm inexperienced programmer, haven't been able figure out. realise may not trivial, maybe can me little on way this?
that code reads state of several switches can pressed @ same time. can setup handle multiple switches being pressed @ same time? doubt it.
that code cares how long switches pressed. care?
that code cares how long switches pressed. care?
Arduino Forum > Using Arduino > Programming Questions > Rewrite button interupt on multiple pins to one pin
arduino
Comments
Post a Comment