E=MC
/
e=mc
.
main.cpp
- Committer:
- ericoneill
- Date:
- 2015-02-25
- Revision:
- 0:d328ecb3fbb1
- Child:
- 1:8e5821dec0f7
File content as of revision 0:d328ecb3fbb1:
#include "mbed.h" DigitalOut myled(LED1); PwmOut servo(PTA5); PwmOut motor(PTA4); Serial pc(USBTX, USBRX); // tx, rx void motor_sweep() { for(float p = 0.0; p<.0025; p+=.0001){ motor.pulsewidth(p); if(p == 0.0 || p == 1.0 || p == .0007){ wait(2); } wait(.1); } } void servo_sweep(){ for(float p = 0.001; p<0.002; p+=0.0001){ servo.pulsewidth(p); wait(0.5); } } int main() { servo.period(0.005); motor.period(.0025); while(1){ char choice = pc.getc(); //pc.putc(choice); switch(choice){ case '0': motor.pulsewidth(0.0); pc.printf("0% \n"); break; case '1': motor.pulsewidth(.0025); pc.printf("100% \n"); break; case '3': motor.pulsewidth(.0025*.3); pc.printf("30% \n"); break; case '5': motor.pulsewidth(.0025*.5); pc.printf("50% \n"); break; default: motor.pulsewidth(.0025*.3); pc.printf("default"); break; } //servo_sweep(); //motor_sweep(); //motor.pulsewidth(.0025); } }