Mario Bambagini / Mbed 2 deprecated caterpillar

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers dc_motor.cpp Source File

dc_motor.cpp

00001 #include "dc_motor.hpp"
00002 
00003 DC_motor::DC_motor (PinName ppwm, PinName pdir): pwm(ppwm), dir(pdir)
00004 {
00005     pwm.period(0.001);
00006     pwm = 0;
00007     dir = 0;
00008 }
00009 
00010 void DC_motor::speed (float speed)
00011 {
00012     dir = speed>0.0;
00013     pwm = abs(speed);
00014 }