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.
Revision 0:9dfac5da16a9, committed 2011-01-25
- Comitter:
- shimniok
- Date:
- Tue Jan 25 00:05:16 2011 +0000
- Commit message:
- Initial Version
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Jan 25 00:05:16 2011 +0000
@@ -0,0 +1,38 @@
+#include "mbed.h"
+
+// MaxSonar EZ1 test program
+// by Michael Shimniok http://www.bot-thoughts.com/
+//
+// Based on datasheet here: http://www.maxbotix.com/uploads/LV-MaxSonar-EZ1-Datasheet.pdf
+// Reads from AN (analog) pin connected to mbed p20, assumes 3.3V supply to EZ1 module.
+//
+// mbed -> EZ1
+// -----------
+// VOUT -> +5
+// GND -> GND
+// p20 -> AN
+//
+
+AnalogIn ain(p20);
+Serial pc(USBTX, USBRX); // tx, rx
+
+int main() {
+ float adc, volts, inches;
+ int feet, in;
+
+ pc.baud(115200);
+
+ while (1){
+ adc = ain.read(); // read analog as a float
+ volts = adc * 3.3; // convert to volts
+ inches = volts / 0.0064; // 3.3V supply: 6.4mV per inch
+ feet = (int) inches / 12; // inches to feet (trunc)
+ in = (int) inches % 12; // remainder -> in(ches)
+
+ pc.printf("%8.2f adc %8.2fV %8.2f in %d'%d\"\n", adc, volts, inches, feet, in);
+
+ wait(0.05); // 20Hz update rate ; note we aren't truly synchronized to the device or anything...
+ }
+}
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Jan 25 00:05:16 2011 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e