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:41d3bf4a7ce2
- Child:
- 1:040ce5e7720a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sun May 10 14:03:16 2020 +0000
@@ -0,0 +1,29 @@
+/*
+ * Inventor's kit for micor:bit
+ * Experiment 1: Say "Hello"to the BBC micro:bit
+*/
+
+#include "MicroBit.h"
+
+MicroBit uBit;
+MicroBitImage sun("255,0,255, 0,255\n0,255,255,255,0\n255,255,255,255,255\n0,255,255,255,0\n255,0,255,0,255\n");
+MicroBitImage moon("255,255,255,0,0\n0,255,255,255,0\n0,0,255,255,0\n0,255,255,255,0\n255,255,255,0,0\n");
+// using p0 as analog pin
+int main()
+{
+ // Initialise the micro:bit runtime.
+ uBit.init();
+
+ MicroBitPin P0(MICROBIT_ID_IO_P0, MICROBIT_PIN_P0, PIN_CAPABILITY_ALL);
+
+ // loop
+ while(1)
+ {
+ if (P0.getAnalogValue() >= 512) // P0 is a value in the range of 0 - 1024
+ uBit.display.print(sun);
+ else
+ uBit.display.print(moon);
+ }
+
+}
+