Mechatro example program

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 // Motor Control ... Mechatronics example program
00002 //
00003 // 2017.10.05 ... Y.Kuroda
00004 //
00005 #include "mbed.h"
00006 
00007 PwmOut      a1(D1);
00008 DigitalOut  a2(D12);
00009 
00010 int main() {
00011 
00012     a1.period_ms(1);
00013 
00014     while(1) {
00015         a1 = 0.1;   // duty is 10%
00016         a2 = 0;
00017         wait(3);    // 3 s
00018 
00019         a1 = 0.9;   // duty is 10%!!!
00020         a2 = 1;
00021         wait(3);    // 3 sec
00022     }
00023 }