casat

Dependencies:   mbed-src FATFileSystem1515 SDFileSystem1515 Camera_LS_Y201_CANSAT

Fork of CANSAT_CAMERA_servo by Omar Hagrass

Revision:
4:dfb4154c597b
Parent:
2:248e3594ca61
diff -r ff47827160f8 -r dfb4154c597b main2.cpp
--- a/main2.cpp	Wed Sep 09 16:45:49 2015 +0000
+++ b/main2.cpp	Wed Sep 09 23:20:05 2015 +0000
@@ -1,9 +1,9 @@
   #include "mbed.h"
 #include "Camera_LS_Y201.h"
 #include "SDFileSystem.h"
-#include "Servo.h"
+
 
-Servo myservo(p23);
+DigitalOut myservo(p20);
 //#include "FATFileSystem.h"
 Serial xbee(p28,p27);
 Serial pc(USBTX,USBRX);
@@ -28,7 +28,33 @@
 } work_t;
 
 work_t work;
+/////////////////////////servo
+Timer timer1;
+void servo(float p)
+{
+    int x=1;
+while(x<=10)
+{
 
+timer1.start();
+
+    while(timer1.read_ms()<p)
+    {
+        myservo=1;
+     }
+        
+     
+        while(timer1.read_ms()<20)
+        {
+            myservo=0;
+        }
+        timer1.reset();
+
+x++;
+}
+}
+
+///////////////////////////servo
   
   
     uint8_t send[16] = {
@@ -180,7 +206,7 @@
  *
  * @return Return 0 if it succeed.
  */
- float p=0.1;//////////////servo
+ float p=0.9;//////////////servo
  int flag=1;///////////////servo
 int capture(Camera_LS_Y201 *cam, char *filename) {
     /*
@@ -189,23 +215,23 @@
 if(end==true)
 {
     ///////////////////////////////////////////servo
-     myservo = p;
-     //pc.printf("hhhhhhh%fhhhh",p);
+     servo(p);
+     pc.printf("hhhhhhh%fhhhh",p);
     if (flag==1)        
     {
-        p+=0.1;
+        p+=0.6;
     }
     else
     {
-        p-=0.1;
+        p-=0.6;
         }
-    if(p>0.9)
+    if(p>1.5)
     
     {
     flag=0;
     }
     
-    if(p<0.1)
+    if(p<0.9)
     {
     flag=1;
      }