casat

Dependencies:   mbed-src FATFileSystem1515 SDFileSystem1515 Camera_LS_Y201_CANSAT

Fork of CANSAT_CAMERA_servo by Omar Hagrass

Files at this revision

API Documentation at this revision

Comitter:
Hagrass
Date:
Wed Sep 09 23:20:05 2015 +0000
Parent:
3:ff47827160f8
Commit message:
vvvvvv

Changed in this revision

Servo.lib Show diff for this revision Revisions of this file
main2.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Servo.lib	Wed Sep 09 16:45:49 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://developer.mbed.org/users/Hagrass/code/Servo/#0789028dbbc3
--- 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;
      }