Junichi Katsu
/
wallbot_test
It is a test program of wallbot library.
main.cpp@0:ce9fda861f9e, 2013-07-28 (annotated)
- Committer:
- jksoft
- Date:
- Sun Jul 28 08:21:57 2013 +0000
- Revision:
- 0:ce9fda861f9e
First
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jksoft | 0:ce9fda861f9e | 1 | #include "mbed.h" |
jksoft | 0:ce9fda861f9e | 2 | #include "wallbot.h" |
jksoft | 0:ce9fda861f9e | 3 | |
jksoft | 0:ce9fda861f9e | 4 | wallbot wb; |
jksoft | 0:ce9fda861f9e | 5 | |
jksoft | 0:ce9fda861f9e | 6 | BusOut leds(LED1,LED2,LED3,LED4); |
jksoft | 0:ce9fda861f9e | 7 | |
jksoft | 0:ce9fda861f9e | 8 | int main() { |
jksoft | 0:ce9fda861f9e | 9 | |
jksoft | 0:ce9fda861f9e | 10 | wait(0.5); |
jksoft | 0:ce9fda861f9e | 11 | |
jksoft | 0:ce9fda861f9e | 12 | // Motor test. |
jksoft | 0:ce9fda861f9e | 13 | wb.forward(0.5); |
jksoft | 0:ce9fda861f9e | 14 | wait (2.0); |
jksoft | 0:ce9fda861f9e | 15 | wb.left(0.5); |
jksoft | 0:ce9fda861f9e | 16 | wait (2.0); |
jksoft | 0:ce9fda861f9e | 17 | wb.backward(0.5); |
jksoft | 0:ce9fda861f9e | 18 | wait (2.0); |
jksoft | 0:ce9fda861f9e | 19 | wb.right(0.5); |
jksoft | 0:ce9fda861f9e | 20 | wait (2.0); |
jksoft | 0:ce9fda861f9e | 21 | |
jksoft | 0:ce9fda861f9e | 22 | wb.stop(); |
jksoft | 0:ce9fda861f9e | 23 | |
jksoft | 0:ce9fda861f9e | 24 | // Sensor & Switch test. |
jksoft | 0:ce9fda861f9e | 25 | while(1) |
jksoft | 0:ce9fda861f9e | 26 | { |
jksoft | 0:ce9fda861f9e | 27 | int bit; |
jksoft | 0:ce9fda861f9e | 28 | wb.GetLinePosition(&bit); |
jksoft | 0:ce9fda861f9e | 29 | printf("LeftSw:%d RightSw:%d FloorSensor:%X\r\n",wb.GetLeftSw(),wb.GetRightSw(),bit); |
jksoft | 0:ce9fda861f9e | 30 | leds = bit; |
jksoft | 0:ce9fda861f9e | 31 | wait(0.1); |
jksoft | 0:ce9fda861f9e | 32 | } |
jksoft | 0:ce9fda861f9e | 33 | } |