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.
Fork of sagawa_lpc1114 by
TB6612.h
00001 #ifndef MBED_TB6612_H 00002 #define MBED_TB6612_H 00003 00004 #include "mbed.h" 00005 #include "SoftPWM.h" 00006 00007 /** TB6612FNG Library 00008 * 00009 * Example: 00010 * @code 00011 * // Drive the Motor 00012 00013 #include "mbed.h" 00014 #include "TB6612.h" 00015 00016 TB6612 motor(p21,p5,p6); // PWMA,AIN1,AIN2 00017 00018 int main() { 00019 00020 motor = 0.0; // Motor stopped. 00021 00022 while(1) 00023 { 00024 motor = 0.5; // Motor forward. 00025 wait(2.0); 00026 motor = -0.5; // Motor reversal. 00027 wait(2.0); 00028 } 00029 } 00030 00031 * @endcode 00032 */ 00033 00034 class TB6612 { 00035 // Public functions 00036 public: 00037 /** Create a TB6612 connected to the specified pins. 00038 * @param pwm A PwmOut pin, driving the H-bridge enable line to control the speed.(PwmOutに対応したポートを指定します。) 00039 * @param fwd A DigitalOut, set high when the motor should go forward.(DigitalOutに対応したポートを指定します。) 00040 * @param rev A DigitalOut, set high when the motor should go backwards.(DigitalOutに対応したポートを指定します。) 00041 */ 00042 TB6612(PinName pwm, PinName fwd, PinName rev); 00043 /** Directly control the speed and direction of the motor 00044 * 00045 * @param speed A normalised number -1.0 - 1.0 represents the full range. 00046 * @return return the stopped state or direction of rotation. 00047 */ 00048 float speed(float speed); 00049 /** A operator shorthand for speed() 00050 * 00051 */ 00052 void operator= ( float value ) 00053 { 00054 speed(value); 00055 } 00056 operator int() 00057 { 00058 return(stat); 00059 } 00060 00061 protected: 00062 SoftPWM _pwm; 00063 DigitalOut _fwd; 00064 DigitalOut _rev; 00065 int stat; 00066 }; 00067 00068 #endif
Generated on Sat Aug 6 2022 18:01:58 by
1.7.2
