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.
main.cpp@1:afc3bf972645, 2011-09-07 (annotated)
- Committer:
- norberts
- Date:
- Wed Sep 07 10:04:49 2011 +0000
- Revision:
- 1:afc3bf972645
- Parent:
- 0:207850946233
- Child:
- 2:1a24252c8cb1
supertux
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
norberts |
0:207850946233 | 1 | #include "mbed.h" |
norberts |
0:207850946233 | 2 | #include "usbhid.h" |
norberts |
0:207850946233 | 3 | |
norberts |
0:207850946233 | 4 | DigitalOut l1(LED1),l2(LED2); |
norberts |
0:207850946233 | 5 | |
norberts |
0:207850946233 | 6 | Serial pc(USBTX, USBRX); // tx, rx |
norberts |
0:207850946233 | 7 | BusIn bus(p21,p22,p23,p24,p25); |
norberts |
0:207850946233 | 8 | usbhid usb; |
norberts |
0:207850946233 | 9 | |
norberts |
0:207850946233 | 10 | int main() |
norberts |
0:207850946233 | 11 | { |
norberts |
0:207850946233 | 12 | int i=0,j; |
norberts |
0:207850946233 | 13 | |
norberts |
0:207850946233 | 14 | pc.printf("I live! Again ...\r"); |
norberts |
0:207850946233 | 15 | usb.keyboard("rem "); |
norberts |
0:207850946233 | 16 | |
norberts |
0:207850946233 | 17 | while(1){ |
norberts |
0:207850946233 | 18 | wait(.01); |
norberts |
0:207850946233 | 19 | l1=!l1; |
norberts |
0:207850946233 | 20 | j=bus.read(); |
norberts |
0:207850946233 | 21 | if(j){ |
norberts |
1:afc3bf972645 | 22 | l2=1; |
norberts |
0:207850946233 | 23 | //pc.printf("bus: %x i: %d\r",j,i++); |
norberts |
0:207850946233 | 24 | if(j==1) |
norberts |
0:207850946233 | 25 | usb.keyboard(' '); |
norberts |
0:207850946233 | 26 | else if(j==2) |
norberts |
1:afc3bf972645 | 27 | usb.keyboard('w'); // up |
norberts |
0:207850946233 | 28 | else if(j==4) |
norberts |
1:afc3bf972645 | 29 | usb.keyboard('s'); // down |
norberts |
0:207850946233 | 30 | else if(j==8) |
norberts |
1:afc3bf972645 | 31 | usb.keyboard('a'); // left |
norberts |
0:207850946233 | 32 | else if(j==16) |
norberts |
1:afc3bf972645 | 33 | usb.keyboard('d'); // right |
norberts |
0:207850946233 | 34 | } |
norberts |
1:afc3bf972645 | 35 | else |
norberts |
1:afc3bf972645 | 36 | l2=0; |
norberts |
0:207850946233 | 37 | } |
norberts |
0:207850946233 | 38 | } |