Ilya Khorosh
/
Lab3_Controller
Controller code
main.cpp@0:b1f3cd059526, 2011-10-13 (annotated)
- Committer:
- ikhorosh
- Date:
- Thu Oct 13 03:07:38 2011 +0000
- Revision:
- 0:b1f3cd059526
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ikhorosh | 0:b1f3cd059526 | 1 | #include "mbed.h" |
ikhorosh | 0:b1f3cd059526 | 2 | |
ikhorosh | 0:b1f3cd059526 | 3 | Serial xbee1(p9, p10); |
ikhorosh | 0:b1f3cd059526 | 4 | DigitalOut rst1(p11); |
ikhorosh | 0:b1f3cd059526 | 5 | DigitalOut led1(LED1); |
ikhorosh | 0:b1f3cd059526 | 6 | Serial pc(USBTX, USBRX); |
ikhorosh | 0:b1f3cd059526 | 7 | AnalogIn slider(p15); |
ikhorosh | 0:b1f3cd059526 | 8 | |
ikhorosh | 0:b1f3cd059526 | 9 | int main() { |
ikhorosh | 0:b1f3cd059526 | 10 | rst1 = 0; //Set reset pin to 0 |
ikhorosh | 0:b1f3cd059526 | 11 | |
ikhorosh | 0:b1f3cd059526 | 12 | wait(.5); |
ikhorosh | 0:b1f3cd059526 | 13 | rst1 = 1; //Set reset pin to 1 |
ikhorosh | 0:b1f3cd059526 | 14 | |
ikhorosh | 0:b1f3cd059526 | 15 | wait(.5); |
ikhorosh | 0:b1f3cd059526 | 16 | led1 = 1; |
ikhorosh | 0:b1f3cd059526 | 17 | pc.printf("starting trans"); |
ikhorosh | 0:b1f3cd059526 | 18 | |
ikhorosh | 0:b1f3cd059526 | 19 | char y = 0; |
ikhorosh | 0:b1f3cd059526 | 20 | |
ikhorosh | 0:b1f3cd059526 | 21 | while (1) { |
ikhorosh | 0:b1f3cd059526 | 22 | wait(1); |
ikhorosh | 0:b1f3cd059526 | 23 | y+=10; |
ikhorosh | 0:b1f3cd059526 | 24 | xbee1.putc(slider*100); //XBee write |
ikhorosh | 0:b1f3cd059526 | 25 | pc.printf("%d", y); |
ikhorosh | 0:b1f3cd059526 | 26 | led1 = !led1; |
ikhorosh | 0:b1f3cd059526 | 27 | } |
ikhorosh | 0:b1f3cd059526 | 28 | } |