jspencer
Joined: 22 Dec 2003 Posts: 57 Location: Boise, ID USA
|
|
Posted: Wed May 03, 2006 10:30 am |
|
|
Why not try something like this:
| Code: |
int8 x, y, axis;
short led_bank_select;
void change_led_bank (short bank) {
if (bank) {
// this is the lower bank
axis = input_a() &0xf;
output_b(axis);
} else {
// this is the upper bank
axis = input_a() &0xf;
output_b(axis << 4);
}
}
void main () {
// set this to your default
led_bank_select = TRUE;
y=0;
while (1){
if (input(PIN_A4)) {
// simple debounce to make sure the button was pressed.
for (x=0;x<40;x++){
if (input(PIN_A4))
y++;
// if we hit 20 it is more then likely a valid button press
if (y >= 20) {
led_bank_select = !led_bank_select;
change_led_bank (led_bank_select);
break;
} // end if
delay_ms(5); // delay for a small amount of time between each reading
} // end for
// reset y to 0
y = 0;
} // end if
} // end while
} // end main
|
If anything, maybe it will give you a few ideas. |
|