NervousPuppySprintTwo
Dependencies: C12832_lcd Servo USBHost mbed
Fork of USBHostSerial_HelloWorld by
main.cpp
- Committer:
- hervel90
- Date:
- 2015-03-02
- Revision:
- 7:3b14ddcf6d8e
- Parent:
- 2:8f3478b5d434
- Child:
- 8:eaae889bc6eb
File content as of revision 7:3b14ddcf6d8e:
#include "mbed.h" #include "USBHostSerial.h" #include "C12832_lcd.h" #include "Servo.h" DigitalOut led1(LED1); DigitalOut led3(LED3); Serial pc(USBTX, USBRX); C12832_LCD lcd; Servo tilt(p21); Servo rotate(p22); AnalogIn ainLeft(p15); AnalogIn ainRight(p16); Mutex rx_mutex; int main() { int pos = 1000; tilt.Enable(1000,20000); lcd.cls(); char buffer[128]; while (true) { for(pos=1000;pos<=1250;pos+=1) { tilt.SetPosition(pos); lcd.cls(); lcd.printf(" %d ", pos); //wait(0.5); } for(pos=1250;pos>=1000;pos-=1) { tilt.SetPosition(pos); lcd.printf(" %d ", pos); //wait(0.5); } } /* while (true) { if(pc.readable()) { rx_mutex.lock(); pc.gets(buffer,2); // set the number of bytes rx_mutex.unlock(); lcd.locate(0,1); lcd.printf(buffer); } int x=atoi(buffer); switch (x) { case 0: lcd.cls(); lcd.locate(0,1); lcd.printf("Do nothing"); break; case 1: lcd.cls(); lcd.locate(0,1); lcd.printf("Right"); //thread servo right break; case 2: lcd.cls(); lcd.locate(0,1); lcd.printf("down & right"); break; case 3: lcd.cls(); lcd.locate(0,1); lcd.printf("down"); break; case 4: lcd.cls(); lcd.locate(0,1); lcd.printf("Ddown & left"); break; case 5: lcd.cls(); lcd.locate(0,1); lcd.printf("left"); break; case 6: lcd.cls(); lcd.locate(0,1); lcd.printf("up & left"); break; case 7: lcd.cls(); lcd.locate(0,1); lcd.printf("up"); break; case 8: lcd.cls(); lcd.locate(0,1); lcd.printf("up & left"); break; } } */ }