speed increment for loop
Dependencies: Encoder HIDScope MODSERIAL mbed
main.cpp
- Committer:
- Vigilance88
- Date:
- 2015-09-23
- Revision:
- 2:c8a030f3b4e7
- Parent:
- 1:e0c4625bbbab
- Child:
- 3:e333b4258af4
File content as of revision 2:c8a030f3b4e7:
#include "mbed.h" #include "encoder.h" #include "MODSERIAL.h" int main(){ //VARIABLES AnalogIn potmeter(A1); AnalogIn potmeter2(A0); DigitalIn button(D8); MODSERIAL pc(USBTX,USBRX); Encoder motor1(D13,D12,true); // channel A and B from encoder, true - getSpeed works PwmOut pwm_motor1(D6); // D4 and D5 = motor 2, D7 and D6 = motor 2 DigitalOut dir_motor1(D7); // Encoder motor2(D10,D9,true); // channel A and B from encoder, true - getSpeed works PwmOut pwm_motor2(D5); // D4 and D5 = motor 2, D7 and D6 = motor 2 DigitalOut dir_motor2(D4); // //CODE pc.baud(9600); while (1) { pwm_motor2.period(0.0001); for (float s= 0.0f; s <= 1.1f ; s += 0.01f) { dir_motor2=1; pwm_motor2.write(s); wait(0.1); pc.printf("pwm duty: %f, %d, \n\r", s, motor2.getPosition()); } } }