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:
- 0:d3f1f650e365
diff -r 000000000000 -r d3f1f650e365 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sat Mar 29 04:15:35 2014 +0000
@@ -0,0 +1,48 @@
+#include "mbed.h"
+#include "SonicD.h"
+
+/*class SonicD{
+public:
+ InterruptIn nombre;//(sonicPW);
+ Timer t;
+ SonicD(PinName sonicPW) : nombre(sonicPW){
+ nombre.rise(this, &SonicD::rise_int);
+ nombre.fall(this, &SonicD::get_uS);
+ }
+
+ volatile float dcm;
+ volatile float din;
+
+ float getIn(){
+ din = uS/147.0;
+ return din;
+ }
+ float getCm(){
+ dcm = (uS/147.0)*2.54;
+ return dcm;
+ }
+ void rise_int(){
+ t.start();
+ }
+ void get_uS(){
+ uS = t.read_us();
+ t.reset();
+ }
+
+private:
+ volatile int uS;
+};
+*/
+//---------------------------------------------------------------------
+
+Serial pc(USBTX, USBRX);
+SonicD sensor(PTA12);
+
+int main() {
+ while(1){
+ wait(0.2);
+ int x = sensor.getIn();
+ int y = sensor.getCm();
+ pc.printf("%i in\t%i cm\n", x, y);
+ }
+}