jason berry / Mbed 2 deprecated ServoTest

Dependencies:   mbed Servo

Files at this revision

API Documentation at this revision

Comitter:
jasonberry
Date:
Thu Feb 04 14:45:35 2021 +0000
Parent:
1:0a8f602aeec9
Commit message:
servojason

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	Thu Feb 04 14:45:35 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/jasonberry/code/Servo/#0ff49e165c90
--- a/main.cpp	Wed Dec 10 16:19:08 2014 -0600
+++ b/main.cpp	Thu Feb 04 14:45:35 2021 +0000
@@ -14,27 +14,33 @@
  * limitations under the License.
  */
  
+// Continuously sweep the servo through it's full range
 #include "mbed.h"
+#include "Servo.h"
 
-// Initialize a pins to perform analog input and digital output fucntions
-AnalogIn   ain(A0);
-DigitalOut dout(LED1);
+// Initialize a pins to perform SERIAL and digital output fucntions
 
-int main(void)
-{
-    while (1) {
-        // test the voltage on the initialized analog pin
-        //  and if greater than 0.3 * VCC set the digital pin
-        //  to a logic 1 otherwise a logic 0
-        if(ain > 0.3f) {
-            dout = 1;
-        } else {
-            dout = 0;
-        }
-        
-        // print the percentage and 16 bit normalized values
-        printf("percentage: %3.3f%%\n", ain.read()*100.0f);
-        printf("normalized: 0x%04X \n", ain.read_u16());
-        wait(0.2f);
-    }
-}
+DigitalOut dout(LED1);
+Serial pc(USBTX, USBRX); // tx, rx
+ 
+ 
+Servo myservo1(p21);
+Servo myservo2(p22);
+ 
+int main() {
+   while(1) {
+       for(int i=0; i<100; i++) {
+             myservo1 = i/100.0;
+             myservo2 = i/100.0;
+             wait(0.01);
+             
+         }
+         for(int i=100; i>0; i--) {
+             myservo1 = i/100.0;
+             myservo2 = i/100.0;
+             wait(0.01);
+           
+         }
+     }
+ }
+ 
--- a/mbed.bld	Wed Dec 10 16:19:08 2014 -0600
+++ b/mbed.bld	Thu Feb 04 14:45:35 2021 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/
\ No newline at end of file
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file