embebidos grupo1 / Mbed 2 deprecated piccolotaller1

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
camilobar
Date:
Sat Sep 16 02:44:14 2017 +0000
Commit message:
camilo;

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	Sat Sep 16 02:44:14 2017 +0000
@@ -0,0 +1,140 @@
+#include "mbed.h"
+#define MAXPOS 50
+#define SS_TIME 500
+ 
+PwmOut myServoX(PB_3);
+PwmOut myServoY(PB_4);
+PwmOut myServoZ(PB_5);
+ 
+ 
+int coord2us(float coord)
+{
+    if(0 <= coord <= MAXPOS)
+        return int(750+coord*1900/50);// 
+    return 750;
+ 
+}
+ 
+void vertex2d(float x, float y, float z){//llamado una funcion coordenada con variables decimal en x,y 
+ 
+    int pulseX = coord2us(x);
+    int pulseY = coord2us(y);
+    int pulseZ = coord2us(z);
+    myServoX.pulsewidth_us(pulseX);
+    myServoY.pulsewidth_us(pulseY);
+    myServoZ.pulsewidth_us(pulseZ);
+    wait_ms(SS_TIME);
+ 
+}
+void home()
+{
+    
+vertex2d(0 ,0,1);
+}    
+ 
+void maxpos()
+{
+vertex2d(MAXPOS ,MAXPOS,0);
+}    
+ 
+void diag()
+{
+    vertex2d(15,0,0); 
+    vertex2d(15,0,10);
+    vertex2d(15,20,10);
+    vertex2d(15,50,10);
+    vertex2d(15,50,0);
+   
+    
+    }
+    void diag2()
+{
+    vertex2d(15,25,0); 
+    vertex2d(15,25,10);
+    vertex2d(10,35,10);
+    vertex2d(0,50,10);
+    
+    vertex2d(0,50,0);
+   
+    
+    }
+    
+void square(float x, float y, float l)
+{
+    int i,j;
+    int p,t;
+   vertex2d(x,y,0);  
+   wait(1);
+   vertex2d(x,y,10);
+   wait(1);
+    p=l;
+    i=p;
+    j=y;
+    vertex2d(i,j/2,10);
+
+    t=l;
+    j=t;
+    vertex2d(i,j,10);
+    p=l;
+    i=p;
+    vertex2d(x,j,10);
+  
+   vertex2d(x,y,10);
+    vertex2d(x,y,0);    
+     vertex2d(0,0,0); 
+}
+void line(float Xi,float Xf,float Yi,float Yf){   
+   int i,j;
+   i=Xi;
+   j=Yi;
+    vertex2d(Xi,Yi,0);  
+   vertex2d(i,j,10);
+   wait(2);
+   i=Xf;
+   j=Yf;
+    vertex2d(i,j,10);
+    wait(2);
+    vertex2d(Xf,Yf,0);    
+    vertex2d(0,0,0); 
+   
+  }
+void circle(int X,int Y,int R){   
+   float resolucion=10,i,j;
+   double PI=3.1416;
+     vertex2d(X,Y,0);  
+   wait(1);
+   for (double angulo=0;angulo<=370;angulo =angulo+resolucion){
+   double radian=((angulo * PI)/180);
+    j=R * cos(radian);
+    i=R * sin(radian);
+    vertex2d(X+i,Y+j,10);
+  
+   }
+  }     
+     
+int main() {
+     // configuracion de  periodo
+    myServoX.period_ms(10);
+    myServoY.period_ms(10);
+    myServoZ.period_ms(20);
+    
+    while(1)
+    {
+  
+      //home();
+     //wait(1);
+    diag2();    
+     wait(1);
+      diag();
+      wait(1);
+     square(0,0,25);
+      wait(5);
+      //line(0,30,0,30);
+     //wait(5);
+      circle(35,20,8); //coordenada x y seguido del radio
+      wait(5);
+      
+      
+     }
+ 
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Sep 16 02:44:14 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/a330f0fddbec
\ No newline at end of file