for BLE Nano v1 INPUT : Analog OUTPUT : USB Serial
Dependencies: BLE_API mbed nRF51822
main.cpp
- Committer:
- electricbaka
- Date:
- 2018-07-12
- Revision:
- 0:42bf46ed69f7
File content as of revision 0:42bf46ed69f7:
/* * * 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); } }