4180Lab2Part7: used to create reversible DC motor with speed control

Dependencies:   Motor mbed

Fork of Motor_HelloWorld by Simon Ford

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 // Sweep the motor speed from full-speed reverse (-1.0) to full speed forwards (1.0)
00002 
00003 #include "mbed.h"
00004 #include "Motor.h"
00005 
00006 Motor m(p21, p6, p5); // pwm, fwd, rev
00007 AnalogIn pot(p20); // cookin
00008 
00009 int main() {
00010     
00011     float r = pot.read();
00012     
00013     while(1){
00014            m.speed(pot); 
00015            wait(0.02);
00016     }
00017 }