Camilo Ramirez / Mbed 2 deprecated pruebaservo1

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 PwmOut sg90azul(PB_9);//SE NOMBRA OBJETO Y SE ESTABLECE PIN DEL OBJETO
00003 DigitalOut ledgrande(LED1);//SE PROGRAMA EL LED A UTILIZAR 
00004 int a=1,x=500;
00005 int main() 
00006 { 
00007     sg90azul.period_ms(20);
00008     while (a<=18)
00009     {
00010         sg90azul.pulsewidth_us(x);
00011         wait_ms(1000);
00012         x=x+120;
00013         a++;
00014         if(a==18)
00015         {
00016             while(a>1)
00017             {
00018                 sg90azul.pulsewidth_us(x);
00019                 wait_ms(1000);
00020                 x=x-120;
00021                 a--; 
00022             }
00023         }
00024     }
00025 }