Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 2:1a24252c8cb1
- Parent:
- 1:afc3bf972645
- Child:
- 3:13401b125368
--- a/main.cpp Wed Sep 07 10:04:49 2011 +0000 +++ b/main.cpp Sat Nov 19 18:18:21 2011 +0000 @@ -4,35 +4,35 @@ DigitalOut l1(LED1),l2(LED2); Serial pc(USBTX, USBRX); // tx, rx -BusIn bus(p21,p22,p23,p24,p25); +BusIn bus(p21,p23,p24,p25,p26); usbhid usb; -int main() -{ - int i=0,j; - +char k[]={' ','w','s','a','d'}; //fudlr + +int main() { + int i,b,lb=0,s; + pc.printf("I live! Again ...\r"); - usb.keyboard("rem "); - - while(1){ + + while (1) { wait(.01); l1=!l1; - j=bus.read(); - if(j){ + b=bus.read(); + + if (b!=lb) { l2=1; - //pc.printf("bus: %x i: %d\r",j,i++); - if(j==1) - usb.keyboard(' '); - else if(j==2) - usb.keyboard('w'); // up - else if(j==4) - usb.keyboard('s'); // down - else if(j==8) - usb.keyboard('a'); // left - else if(j==16) - usb.keyboard('d'); // right - } - else + if (b) { + for (i=0; i<5; i++) { + s=(b&(1<<i))!=0; + if (s) + usb.keyboard2(k[i]); + } + } else + usb.keyboard2(0); + + lb=b; + } else l2=0; } + }