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@0:d5fb9ba6c4c5, 2010-06-29 (annotated)
- Committer:
- IPAB
- Date:
- Tue Jun 29 11:38:25 2010 +0000
- Revision:
- 0:d5fb9ba6c4c5
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| IPAB | 0:d5fb9ba6c4c5 | 1 | #include "mbed.h" |
| IPAB | 0:d5fb9ba6c4c5 | 2 | #include "Koala.h" |
| IPAB | 0:d5fb9ba6c4c5 | 3 | |
| IPAB | 0:d5fb9ba6c4c5 | 4 | |
| IPAB | 0:d5fb9ba6c4c5 | 5 | Serial PC(USBTX,USBRX); |
| IPAB | 0:d5fb9ba6c4c5 | 6 | Koala koala(p28,p27,38400); // tx, rx, baudrate |
| IPAB | 0:d5fb9ba6c4c5 | 7 | |
| IPAB | 0:d5fb9ba6c4c5 | 8 | // Just to check different speeds. |
| IPAB | 0:d5fb9ba6c4c5 | 9 | #define SPEED 3 |
| IPAB | 0:d5fb9ba6c4c5 | 10 | #define LS 3 |
| IPAB | 0:d5fb9ba6c4c5 | 11 | #define RS -5 |
| IPAB | 0:d5fb9ba6c4c5 | 12 | |
| IPAB | 0:d5fb9ba6c4c5 | 13 | |
| IPAB | 0:d5fb9ba6c4c5 | 14 | int main() { |
| IPAB | 0:d5fb9ba6c4c5 | 15 | |
| IPAB | 0:d5fb9ba6c4c5 | 16 | PC.baud(38400); |
| IPAB | 0:d5fb9ba6c4c5 | 17 | |
| IPAB | 0:d5fb9ba6c4c5 | 18 | PC.printf("\r\nKoala Test Code\r\n"); |
| IPAB | 0:d5fb9ba6c4c5 | 19 | PC.printf("=================================\r\n"); |
| IPAB | 0:d5fb9ba6c4c5 | 20 | PC.printf("Initialising...\r\n"); |
| IPAB | 0:d5fb9ba6c4c5 | 21 | |
| IPAB | 0:d5fb9ba6c4c5 | 22 | |
| IPAB | 0:d5fb9ba6c4c5 | 23 | PC.printf("Initialising position (0,0)\r\n%c\r\n",koala.set_pos_cnt(0,0)); |
| IPAB | 0:d5fb9ba6c4c5 | 24 | |
| IPAB | 0:d5fb9ba6c4c5 | 25 | PC.printf("Moving with speed (%d,%d)\r\n%c\r\n",LS*SPEED,RS*SPEED,koala.set_speed(LS*SPEED,RS*SPEED)); |
| IPAB | 0:d5fb9ba6c4c5 | 26 | wait(2); |
| IPAB | 0:d5fb9ba6c4c5 | 27 | PC.printf("Stop moving...\r\n%c\r\n",koala.set_speed(0,0)); |
| IPAB | 0:d5fb9ba6c4c5 | 28 | wait(0.5); |
| IPAB | 0:d5fb9ba6c4c5 | 29 | |
| IPAB | 0:d5fb9ba6c4c5 | 30 | int nCountL,nCountR; |
| IPAB | 0:d5fb9ba6c4c5 | 31 | koala.read_position(&nCountL,&nCountR); |
| IPAB | 0:d5fb9ba6c4c5 | 32 | PC.printf("Counts:\t%d\t%d\r\n",nCountL,nCountR); |
| IPAB | 0:d5fb9ba6c4c5 | 33 | wait(1); |
| IPAB | 0:d5fb9ba6c4c5 | 34 | |
| IPAB | 0:d5fb9ba6c4c5 | 35 | /* Read channel input |
| IPAB | 0:d5fb9ba6c4c5 | 36 | for (int i=0;i<1000;i++) { |
| IPAB | 0:d5fb9ba6c4c5 | 37 | |
| IPAB | 0:d5fb9ba6c4c5 | 38 | PC.printf("Ears:\t%d\t%d\r\n",koala.read_channel(0),koala.read_channel(1)); |
| IPAB | 0:d5fb9ba6c4c5 | 39 | } |
| IPAB | 0:d5fb9ba6c4c5 | 40 | */ |
| IPAB | 0:d5fb9ba6c4c5 | 41 | } |