NervousPuppySprintTwo

Dependencies:   C12832_lcd Servo USBHost mbed

Fork of USBHostSerial_HelloWorld by Samuel Mokrani

Files at this revision

API Documentation at this revision

Comitter:
hervel90
Date:
Mon Mar 02 15:20:18 2015 +0000
Parent:
6:8187c47c0240
Child:
8:eaae889bc6eb
Commit message:
NervousPuppySprintTwo

Changed in this revision

C12832_lcd.lib Show annotated file Show diff for this revision Revisions of this file
Servo.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/C12832_lcd.lib	Mon Mar 02 15:20:18 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/dreschpe/code/C12832_lcd/#8f86576007d6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Servo.lib	Mon Mar 02 15:20:18 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/jdenkers/code/Servo/#352133517ccc
--- a/main.cpp	Thu Mar 14 14:24:09 2013 +0000
+++ b/main.cpp	Mon Mar 02 15:20:18 2015 +0000
@@ -1,40 +1,119 @@
 #include "mbed.h"
 #include "USBHostSerial.h"
+#include "C12832_lcd.h"
+#include "Servo.h"
 
-DigitalOut led(LED1);
+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;
+
 
-void serial_task(void const*) {
-    USBHostSerial serial;
+int main()
+{
+    int pos = 1000;
+    tilt.Enable(1000,20000);
+    lcd.cls();
+    char buffer[128];
     
-    while(1) {
+    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);
+        }
+    
+    }
+    
+    
     
-        // try to connect a serial device
-        while(!serial.connect())
-            Thread::wait(500);
-        
-        // in a loop, print all characters received
-        // if the device is disconnected, we try to connect it again
-        while (1) {
-        
-            // if device disconnected, try to connect it again
-            if (!serial.connected())
-                break;
+/*    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");
 
-            // print characters received
-            while (serial.available()) {
-                printf("%c", serial.getc());
-            }
+            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;
             
-            Thread::wait(50);
+            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;
         }
-    }
+    } */
 }
-
-int main() {
-    Thread serialTask(serial_task, NULL, osPriorityNormal, 256 * 4);
-    while(1) {
-        led=!led;
-        Thread::wait(500);
-    }
-}
\ No newline at end of file