E=MC
/
e=mc
.
main.cpp
- Committer:
- ericoneill
- Date:
- 2015-02-27
- Revision:
- 1:8e5821dec0f7
- Parent:
- 0:d328ecb3fbb1
- Child:
- 2:30ebae0d3e17
File content as of revision 1:8e5821dec0f7:
#include "mbed.h" DigitalOut myled(LED1); PwmOut servo(PTA5); PwmOut motor(PTA4); Serial pc(USBTX, USBRX); // tx, rx DigitalIn din(PTA13); Timer t; 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); int previous_val = -1; t.start(); int timechange = 0; while(1){ if(din) { if(previous_val = 0){ } myled = 1; pc.printf("dark"); } else { myled = 0; pc.printf("light"); } wait(.2f); //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); } }