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.cpp
00001 #include "TB6612FNG.h" 00002 00003 TB6612FNG::TB6612FNG(){ 00004 } 00005 00006 TB6612FNG::TB6612FNG(PinName idir1, PinName idir2, PinName ipwm, PinName istby){ 00007 config(idir1,idir2,ipwm,istby); 00008 } 00009 00010 void TB6612FNG::config(PinName idir1, PinName idir2, PinName ipwm, PinName istby){ 00011 dir1 = new DigitalOut(idir1); 00012 dir2 = new DigitalOut(idir2); 00013 pwm = new PwmOut(ipwm); 00014 stby = new DigitalOut(istby); 00015 stop(); 00016 } 00017 00018 void TB6612FNG::start(){ 00019 on = true; 00020 *dir1 = 1; 00021 *dir2 = 1; 00022 *pwm = 0; 00023 *stby = 1; 00024 } 00025 00026 void TB6612FNG::stop(){ 00027 *dir1 = 0; 00028 *dir2 = 0; 00029 *pwm = 1; 00030 } 00031 00032 void TB6612FNG::standby(){ 00033 on = false; 00034 *dir1 = 0; 00035 *dir2 = 0; 00036 *pwm = 1; 00037 *stby = 0; 00038 } 00039 00040 void TB6612FNG::fwd(float speed){ 00041 if(on && speed <= 1){ 00042 *dir1 = 1; 00043 *dir2 = 0; 00044 *pwm = speed; 00045 } 00046 } 00047 00048 void TB6612FNG::rev(float speed){ 00049 if(on && speed <= 1){ 00050 *dir1 = 0; 00051 *dir2 = 1; 00052 *pwm = speed; 00053 } 00054 }
Generated on Sun Jul 17 2022 11:29:04 by
1.7.2
