Skip to content

Instantly share code, notes, and snippets.

@khanning
Created May 14, 2019 17:03
Show Gist options
  • Save khanning/19753c1a0f978117b992c60668d09d1c to your computer and use it in GitHub Desktop.
Save khanning/19753c1a0f978117b992c60668d09d1c to your computer and use it in GitHub Desktop.
#include "MicroBit.h"
MicroBit uBit;
MicroBitSerial serial(USBTX, USBRX);
uint8_t lightLevel;
void lightLevelReady(MicroBitEvent) {
lightLevel = uBit.display.readLightLevel();
serial.send(lightLevel);
serial.send("\r\n");
}
int main() {
uBit.init();
uBit.messageBus.listen(MICROBIT_ID_DISPLAY, MICROBIT_DISPLAY_EVT_LIGHT_SENSE, lightLevelReady);
uBit.display.readLightLevel();
while (1) {
fiber_sleep(20);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment