Created
May 14, 2019 17:03
-
-
Save khanning/19753c1a0f978117b992c60668d09d1c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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