Enabling the analog to digital converter (ADC) on the BBC Micro:bit using C/C++
To get the example ADC code to work on the Lancaster Github site, change the line:
[code language=“shell” light=“true”] MicroBitPin P0(MICROBIT_ID_IO_P0, MICROBIT_PIN_P0, PIN_CAPABILITY_BOTH); [/code]
To:
[code language=“shell” light=“true”] MicroBitPin P0(MICROBIT_ID_IO_P0, MICROBIT_PIN_P0, PIN_CAPABILITY_ANALOG); [/code]
I tested this using both the online Mbed compiler and the yotta compiler.