servo control via ticker

Dependencies:   mbed Servo

Files at this revision

API Documentation at this revision

Comitter:
jasonberry
Date:
Tue Mar 16 12:20:58 2021 +0000
Parent:
0:5014bf742e9b
Commit message:
servo control via ticker

Changed in this revision

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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Servo.lib	Tue Mar 16 12:20:58 2021 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/Servo/#36b69a7ced07
--- a/main.cpp	Thu Feb 14 14:30:22 2013 +0000
+++ b/main.cpp	Tue Mar 16 12:20:58 2021 +0000
@@ -1,17 +1,37 @@
 #include "mbed.h"
+#include "Servo.h"
+
+Servo s1(p21);
+Servo s2(p22);
+
  
 Ticker flipper;
+
 DigitalOut led1(LED1);
 DigitalOut led2(LED2);
  
 void flip() {
     led2 = !led2;
+    s1 = s1+0.005;
+    s2 = s2+0.005;
+    
+    if(s1 == 1)
+        s1 = 0;
+    if(s2 == 1)
+        s2 =0;
 }
  
 int main() {
+    
     led2 = 1;
-    flipper.attach(&flip, 2.0); // the address of the function to be attached (flip) and the interval (2 seconds)
+    flipper.attach(&flip, 0.01); // the address of the function to be attached (flip) and the interval (2 seconds)
  
+    s1.calibrate(0.00105, 45.0); 
+    s2.calibrate(0.00105, 45.0);
+    
+    s1=0;
+    s2=0;
+    
     // spin in a main loop. flipper will interrupt it to call flip
     while(1) {
         led1 = !led1;
--- a/mbed.bld	Thu Feb 14 14:30:22 2013 +0000
+++ b/mbed.bld	Tue Mar 16 12:20:58 2021 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/0954ebd79f59
\ No newline at end of file
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file