Ultrasonic distance meter mede with micro:bit and Grove Inventor Kit

Dependencies:   DigitDisplay RangeFinder microbit

Fork of microbit-component-display by BBC

Files at this revision

API Documentation at this revision

Comitter:
ytsuboi
Date:
Thu Aug 24 09:05:15 2017 +0000
Parent:
0:0c37474c8541
Commit message:
first commit

Changed in this revision

DigitDisplay.lib Show annotated file Show diff for this revision Revisions of this file
RangeFinder.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
microbit.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 0c37474c8541 -r ed667cae3667 DigitDisplay.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DigitDisplay.lib	Thu Aug 24 09:05:15 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/Seeed/code/DigitDisplay/#d3173c8bfd48
diff -r 0c37474c8541 -r ed667cae3667 RangeFinder.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RangeFinder.lib	Thu Aug 24 09:05:15 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/NickRyder/code/RangeFinder/#cf496fb70317
diff -r 0c37474c8541 -r ed667cae3667 main.cpp
--- a/main.cpp	Wed Apr 20 14:01:36 2016 +0000
+++ b/main.cpp	Thu Aug 24 09:05:15 2017 +0000
@@ -1,13 +1,23 @@
-/* See 
- * http://lancaster-university.github.io/microbit-docs/advanced/ 
- * for docs about using the micro:bit library
-*/
 #include "MicroBit.h"
+#include "DigitDisplay.h"
+#include "RangeFinder.h"
 
 MicroBitDisplay display;
+//DigitDisplay digit(P0_3, P0_22); // P0/P14
+DigitDisplay digit(P0_2, P0_21); // P1/P15
+
+RangeFinder rf(P0_3, 10, 5800.0, 100000);
 
 int main()
 {
-    while(1)
-        display.scroll(":)");
+    float d;
+
+    while(1) {
+        d = rf.read_m() * 100;
+        digit.write(0,(int)d / 1000 % 10);
+        digit.write(1,(int)d / 100 % 10);
+        digit.write(2,(int)d / 10 % 10);
+        digit.write(3,(int)d / 1 % 10);
+        wait(1);
+    }
 }
\ No newline at end of file
diff -r 0c37474c8541 -r ed667cae3667 microbit.lib
--- a/microbit.lib	Wed Apr 20 14:01:36 2016 +0000
+++ b/microbit.lib	Thu Aug 24 09:05:15 2017 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/teams/Lancaster-University/code/microbit/#9cbea9993ef1
+https://developer.mbed.org/teams/Lancaster-University/code/microbit/#4b89e7e3494f