for BLE Nano v1 INPUT : Analog OUTPUT : USB Serial
Dependencies: BLE_API mbed nRF51822
Diff: main.cpp
- Revision:
- 0:42bf46ed69f7
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Jul 12 15:48:28 2018 +0000 @@ -0,0 +1,42 @@ +/* + * + * BLE Nano1 : USB Serial Communication + * + * http://jellyware.jp/kurage/ + * + */ + + +//------------------------------------------------------------ +//Include Header Files +//------------------------------------------------------------ +#include "mbed.h" + + +//------------------------------------------------------------ +//Definition +//------------------------------------------------------------ +#define ANALOG_IN_PIN1 P0_4 + + +//------------------------------------------------------------ +//Object generation +//------------------------------------------------------------ +AnalogIn ANALOG1(ANALOG_IN_PIN1); +Serial pc(P0_9, P0_11); + +int main(void) +{ + pc.baud(9600); + char str[10]; + + while (true) { + float s = ANALOG1; + uint16_t value = s * 1024; + + sprintf(str, "%d\r\n", value); + pc.printf(str); + + wait_ms(1); + } +} \ No newline at end of file