library for the motor driver
Dependents: 4180_final_project
Fork of libTCS34725 by
TB6612FNG.cpp
- Committer:
- mwilkens241
- Date:
- 2017-03-22
- Revision:
- 5:822a7407ccb3
- Parent:
- TCA9548.cpp@ 4:cc00e3842f1b
- Child:
- 7:e1be74ebe7be
File content as of revision 5:822a7407ccb3:
#include "TB6612FNG.h" TB6612FNG::TB6612FNG(){ } TB6612FNG::TB6612FNG(PinName idir1, PinName idir2, PinName ipwm, PinName istby){ config(idir1,idir2,ipwm,istby); } void TB6612FNG::config(PinName idir1, PinName idir2, PinName ipwm, PinName istby){ dir1 = new DigitalOut(idir1); dir2 = new DigitalOut(idir2); pwm = new PwmOut(ipwm); stby = new DigitalOut(istby); stop(); } void TB6612FNG::start(){ on = true; *dir1 = 1; *dir2 = 1; *pwm = 0; *stby = 0; } void TB6612FNG::stop(){ on = false; *dir1 = 0; *dir2 = 0; *pwm = 1; *stby = 1; } void TB6612FNG::fwd(float speed){ if(on && speed <= 1){ *dir1 = 1; *dir2 = 0; *pwm = speed; } } void TB6612FNG::rev(float speed){ if(on && speed <= 1){ *dir1 = 0; *dir2 = 1; *pwm = speed; } }