![](/media/cache/profiles/d707329bece455a462b58ce00d1194c9.50x50_q85.jpg)
Revision 0:74b4b9fc9480, committed 2010-06-04
- Comitter:
- alex89
- Date:
- Fri Jun 04 10:23:46 2010 +0000
- Commit message:
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/keypad.cpp Fri Jun 04 10:23:46 2010 +0000 @@ -0,0 +1,68 @@ +#include "main.h" + +int getKeyNum(){ + +DigitalIn col1(p18); +DigitalIn col2(p20); +DigitalIn col3(p16); + +DigitalOut row1(p19); +DigitalOut row2(p14); +DigitalOut row3(p15); +DigitalOut row4(p17); + + row1 = 1; + row2 = 0; + row3 = 0; + row4 = 0; + + if (col1) + return 1; + else if (col2) + return 2; + else if (col3) + return 3; + + row1 = 0; + row2 = 1; + row3 = 0; + row4 = 0; + + if (col1) + return 4; + else if (col2) + return 5; + else if (col3) + return 6; + + row1 = 0; + row2 = 0; + row3 = 1; + row4 = 0; + + if (col1) + return 7; + else if (col2) + return 8; + else if (col3) + return 9; + + row1 = 0; + row2 = 0; + row3 = 0; + row4 = 1; + + if (col1) + return -2; + else if (col2) + return 0; + else if (col3) + return -3; + + row1 = 0; + row2 = 0; + row3 = 0; + row4 = 0; + + return -1; +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jun 04 10:23:46 2010 +0000 @@ -0,0 +1,26 @@ +#include "main.h" + +Serial xbee1(p9, p10); +DigitalOut rst1(p11); + +DigitalOut myled(LED1); +DigitalOut myled2(LED2); + +int main() { + rst1 = 0; //Set reset pin to 0 + myled = 0; + myled2= 0; + wait_ms(1); + rst1 = 1; //Set reset pin to 1 + wait_ms(1); + + while (1) { + int a = getKeyNum(); + + if(a!=-1){ + myled2 = 1; + xbee1.putc(a); //XBee write + myled2 = 0; + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.h Fri Jun 04 10:23:46 2010 +0000 @@ -0,0 +1,3 @@ +#include "mbed.h" + +int getKeyNum();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Jun 04 10:23:46 2010 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/029aa53d7323