ECE 4180
/
LAB2-Part10-Hbridge
Hbridge Motor Code
Embed:
(wiki syntax)
Show/hide line numbers
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(p22, p13, p14); // pwm, fwd, rev 00007 AnalogIn pot(p20); 00008 00009 int main() { 00010 //for (float s= -1.0; s < 1.0 ; s += 0.1) { 00011 // m.speed(s); 00012 // wait(1); 00013 // } 00014 float control; 00015 while(1){ 00016 control = 2*(1-pot)-1; 00017 m.speed(control); 00018 wait(0.3); 00019 } 00020 00021 }
Generated on Mon Aug 15 2022 17:36:46 by 1.7.2