this profile using UART with ADXL335 accelerometer, but this is can't reach accelerometer sensor.. please help me to fix it
Dependencies: BLE_API mbed nRF51822
Fork of UART_ADXL335 by
Diff: main.cpp
- Revision:
- 14:4dfb61282efb
- Parent:
- 13:15764cc1f12c
- Child:
- 15:34c3e96ce282
--- a/main.cpp Tue Sep 29 12:02:15 2015 +0000 +++ b/main.cpp Wed Oct 11 08:09:08 2017 +0000 @@ -33,6 +33,13 @@ UARTService *uartServicePtr; +Serial pc(USBTX, USBRX); +AnalogIn analog_value1(A0); +AnalogIn analog_value2(A1); +AnalogIn analog_value3(A2); + +DigitalOut led(LED1); + void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params) { DEBUG("Disconnected!\n\r"); @@ -56,6 +63,9 @@ int main(void) { + int x,y,z; + printf("\nAnalogIn Example\n"); + led1 = 1; Ticker ticker; ticker.attach(periodicCallback, 1); @@ -79,7 +89,15 @@ UARTService uartService(ble); uartServicePtr = &uartService; - while (true) { + while (true) + { ble.waitForEvent(); + x = analog_value1.read_u16(); + y = analog_value2.read_u16(); + z = analog_value3.read_u16(); + printf("\r x = %d y = %d z = %d \n",x,y,z); + wait(0.5); } + + }