Interface with Parallax's high speed continuous rotation servo (Activity Bot)

Dependencies:   Tach

Dependents:   EW202FP_Stop

Revision:
0:d6371727ce0c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ContinuousServo.cpp	Fri Mar 02 16:51:35 2018 +0000
@@ -0,0 +1,20 @@
+#include "ContinuousServo.h"
+ 
+ //64 counts per rev
+ 
+ContinuousServo::ContinuousServo(PinName output): servo_(output){
+    servo_.period_ms(50);
+}
+
+void ContinuousServo::speed(float val){
+    //convert val from -1,1 to 1.3 to 1.7
+    if(val<-1.0)
+        val = -1.0;
+    if(val>1.0)
+        val = 1.0;
+    servo_.pulsewidth_us((int)(1500+200*val));
+}
+
+void ContinuousServo::stop(){
+    servo_.pulsewidth_us(0);
+}
\ No newline at end of file