Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: 4180_final_project
Fork of libTCS34725 by
TB6612FNG.h
00001 // TB6612FNG Motor Driver 00002 #ifndef MBED_TB6612FNG_H 00003 #define MBED_TB6612FNG_H 00004 00005 #include "mbed.h" 00006 00007 /** TB6612FNG control class. 00008 * 00009 * Example: 00010 * @code 00011 * //Perform readings on two i2c devices with the same address 00012 * #include "TB6612FNG.h" 00013 * #include "mbed.h" 00014 * 00015 * 00016 * int main() { 00017 * 00018 * while(1) { 00019 * } 00020 * } 00021 * @endcode 00022 */ 00023 00024 class TB6612FNG { 00025 private: 00026 bool on; 00027 00028 DigitalOut *dir1; 00029 DigitalOut *dir2; 00030 PwmOut *pwm; 00031 DigitalOut *stby; 00032 00033 public: 00034 /** Initialize object with default pins */ 00035 TB6612FNG(); 00036 00037 /** Initialize object with specific motor pins 00038 * 00039 * @param idir1 Direction pin (IN1) 00040 * @param idir2 Second direction pin (IN2) 00041 * @param ipwm Motor PWM pin (PWM) 00042 * @param istby SCL pin 00043 */ 00044 TB6612FNG(PinName idir1, PinName idir2, PinName ipwm, PinName istby); 00045 00046 /** Change the pins the motor was initialized with 00047 * 00048 * @param idir1 Direction pin (IN1) 00049 * @param idir2 Second direction pin (IN2) 00050 * @param ipwm Motor PWM pin (PWM) 00051 * @param istby SCL pin 00052 */ 00053 void config(PinName idir1, PinName idir2, PinName ipwm, PinName istby); 00054 00055 /** Enables the motor 00056 */ 00057 void start(); 00058 00059 /** Stops the motor from moving 00060 */ 00061 void stop(); 00062 00063 /** Disables the motor, puts it into standby 00064 */ 00065 void standby(); 00066 00067 /** Sets the motor to move forward at a given speed (as a percent [0,1]) 00068 * @param speed Speed of the motor as a percent [0,1] 00069 */ 00070 void fwd(float speed); 00071 00072 /** Sets the motor to move backward at a given speed (as a percent [0,1]) 00073 * @param speed Speed of the motor as a percent [0,1] 00074 */ 00075 void rev(float speed); 00076 00077 }; 00078 00079 #endif
Generated on Sun Jul 17 2022 11:29:04 by
1.7.2
