Joseph Roberts / Mbed 2 deprecated ESC_Calibrate

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 DigitalOut myled(LED1);
00004 Serial pc(USBTX, USBRX); // tx, rx
00005 
00006 PwmOut      _motor1(p22);
00007 PwmOut      _motor2(p23);
00008 PwmOut      _motor3(p24);
00009 PwmOut      _motor4(p25);
00010 
00011 int main()
00012 {
00013     float period = 1.0 / 500;
00014     _motor1.period(period);
00015     _motor2.period(period);
00016     _motor3.period(period);
00017     _motor4.period(period);
00018     
00019     _motor1.pulsewidth_us(1860);
00020     _motor2.pulsewidth_us(1860);
00021     _motor3.pulsewidth_us(1860);
00022     _motor4.pulsewidth_us(1860);
00023     
00024     myled = 1;
00025     
00026     while(1)
00027     {
00028         if(pc.readable())
00029         {
00030             if(pc.getc() == 'a')
00031             {
00032                 myled = 0;
00033                 _motor1.pulsewidth_us(1060);
00034                 _motor2.pulsewidth_us(1060);
00035                 _motor3.pulsewidth_us(1060);
00036                 _motor4.pulsewidth_us(1060);
00037             }
00038         }
00039     }
00040 }