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: CustomExplorerRobot_test
Diff: BD6212/BD6212.cpp
- Revision:
- 0:ad4667fc5a76
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/BD6212/BD6212.cpp Sat Feb 27 09:20:21 2016 +0000
@@ -0,0 +1,36 @@
+#include "mbed.h"
+#include "BD6212.h"
+
+BD6212::BD6212(PinName fwd, PinName rev) : _fwd(fwd), _rev(rev){
+ _fwd.period_us(20);
+ _rev.period_us(20);
+ _fwd = 0.0f;
+ _rev = 0.0f;
+
+ bspeed = 0.0f;
+}
+
+void BD6212::speed(float speed){
+ _fwd.period_us(20);
+ _rev.period_us(20);
+ if(speed != bspeed){
+ if(speed > 0.0f){
+ _fwd = speed;
+ _rev = 0.0f;
+ }else if(speed < 0.0f){
+ _fwd = 0.0f;
+ _rev = -speed;
+ }else{
+ _fwd = 1.0f;
+ _rev = 1.0f;
+ }
+ bspeed = speed;
+ }
+}
+
+void BD6212::coast(void){
+ _fwd.period_us(20);
+ _rev.period_us(20);
+ _fwd = 0.0f;
+ _rev = 0.0f;
+}
Custom Explorer Robot