![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Library version for DC_Stepper_Controller_Lib with PWM speed control
Dependents: DR-ArmServoTest Auto_DC_pick_class MBed_TR1 ros_button_2021
sample_main.cpp
- Committer:
- howanglam3
- Date:
- 2021-08-16
- Revision:
- 20:a0d027b80d2c
File content as of revision 20:a0d027b80d2c:
/******************************************************* DC MODOR CONTROLLER LIBRARY ******************************************************* IMPORTANT: GO TO README FOR DOCUMENT! ********************************************************/ #include "mbed.h" #include "QEI.h" #include "DC_Motor_Controller.h" DC_Motor_PID motor(D6,D3,D4,D5,792); //M1, M2, INA, INB, PPR DigitalIn but(D7); // angle = 412 degree to move from one to another // angle = 100 degree to DigitalOut led1(LED1); DigitalOut led2(LED2); int main() { Serial pc(USBTX, USBRX); // tx, rx pc.baud(9600); motor.set_pid(0.008, 0, 0, 0.10); but.mode(PullUp); while(1){ wait(0.5); motor.set_out(0,0.4); while(1) { pc.printf("%g \n", but); if(but) { motor.set_out(0,0); pc.printf("\nend: %d \n", motor.get_pulse()); break;} } wait(0.5); motor.reset(); wait(0.5); motor.move_angle(-250); wait(2); } }