Harald Blab / microbit-inventors-kit-ldr-and-analog-input

Dependencies:   microbit

Revision:
1:040ce5e7720a
Parent:
0:41d3bf4a7ce2
Child:
2:06ceb03b798d
--- a/main.cpp	Sun May 10 14:03:16 2020 +0000
+++ b/main.cpp	Sun May 10 15:49:51 2020 +0000
@@ -8,18 +8,16 @@
 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
+        // using p0 as analog pin
+        if (uBit.io.P0.getAnalogValue() >= 512) // P0 is a value in the range of 0 - 1024
             uBit.display.print(sun);
         else 
             uBit.display.print(moon);