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.
main.cpp
- Committer:
- haraldblab
- Date:
- 2020-05-10
- Revision:
- 0:41d3bf4a7ce2
- Child:
- 1:040ce5e7720a
File content as of revision 0:41d3bf4a7ce2:
/*
* 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);
}
}