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.
Diff: main.cpp
- Revision:
- 2:9189fa810ef8
- Parent:
- 1:3f38c4bad274
- Child:
- 3:7c90c4811843
diff -r 3f38c4bad274 -r 9189fa810ef8 main.cpp
--- a/main.cpp Fri Jan 30 01:46:36 2015 +0000
+++ b/main.cpp Sat Feb 21 07:55:05 2015 +0000
@@ -94,10 +94,14 @@
}
}
+// you must adjust center position
+#define RL_ADJ (-120)
+
// RC servo
-void servo (float deg)
+// rl : -1.0 ? 1.0
+void servo (float rl)
{
- servo_pwm.pulsewidth_us(1500 + (int)(500.0 * deg));
+ servo_pwm.pulsewidth_us(1500 + RL_ADJ - (int)(500.0 * rl));
}
void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason)
@@ -129,7 +133,7 @@
// Distance sensor averaging number
#define AVE_SIZE 8
-// Distance constant
+// Distance constant (for Sharp GP2Y0E03)
// Vout[V] = 2.369V - 0.0369*d[cm]
// sample = Vout[V]/3.3V * 0xFFFF
// sample = 47190 - 733.66*d[cm]
@@ -181,7 +185,7 @@
{
// initialize servo & motor
servo_pwm.period_ms(20);
- servo(0.5);
+ servo(0);
motor(0);
Ticker ticker;