Piccolo / Mbed 2 deprecated piccolo

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
manuelitoys
Date:
Wed Sep 06 19:51:43 2017 +0000
Commit message:
prueba

Changed in this revision

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/main.cpp	Wed Sep 06 19:51:43 2017 +0000
@@ -0,0 +1,62 @@
+#include "mbed.h"
+#define MAXPOS 255
+ 
+PwmOut myServoX(PB_3);
+PwmOut myServoY(PB_6);
+PwmOut myServoZ(PB_4);
+ 
+ 
+int coord2pulse(float coord)
+{
+    if(0 <= coord <= MAXPOS)
+        return int(coord*1000/150+750);// us
+    return 750;
+ 
+}
+void draw(){
+    myServoY.pulsewidth_us(750);
+ }
+void nodraw(){
+    myServoY.pulsewidth_us(2000);
+ }
+ 
+void vertex2d(float x, float y){
+ 
+    int pulseX = coord2pulse(x);
+    int pulseY = coord2pulse(y);
+    
+    myServoX.pulsewidth_us(pulseX);
+    myServoY.pulsewidth_us(pulseY);
+ 
+}
+void home()
+{
+vertex2d(0 ,0);
+}    
+ 
+void maxpos()
+{
+vertex2d(MAXPOS ,MAXPOS);
+}    
+ 
+int main() {
+     // configuracion de  periodo
+    myServoX.period_ms(20);
+    myServoY.period_ms(20);
+    myServoZ.period_ms(20);
+    
+    while(1)
+    {
+     draw();
+     wait(3);
+     home();
+     wait(3);
+     maxpos();    
+     wait(3);
+     nodraw();
+     wait(3);
+     
+     }
+ 
+}
+ 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Sep 06 19:51:43 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/a330f0fddbec
\ No newline at end of file