SAADC differential input setup. With EPD display.
Dependencies: GDEP015OC1 acn_nrf52_saadc adc52832_common
main.cpp
- Committer:
- jurica238814
- Date:
- 2017-09-29
- Revision:
- 3:884740fe7de4
- Parent:
- 2:49dab8d9637a
- Child:
- 4:7dd2d8cc90ed
File content as of revision 3:884740fe7de4:
/* * Example to demonstrate usage of the nrf52's SAADC in differential working\ * mode. * * Made by Jurica Resetar @ aconno * jurica_resetar@yahoo.com * More info @ aconno.de * * All rights reserved * */ #include "mbed.h" #include "acd_nrf52_saadc.h" #include "GDEP015OC1.h" #define ANALOG_PIN_P (4) #define ANALOG_PIN_N (5) #define PRINT (1) #if PRINT #include "nrf52_uart.h" NRF52_UART uart(p25, p26, Baud9600); char buffer[255]; #define SEND(...) {uint8_t len = sprintf(buffer, __VA_ARGS__); uart.send(buffer, len);} #else #define SEND(...) #endif SPI spi(p3, NC, p4); GDEP015OC1 epd = GDEP015OC1(spi, p5, p6, p7, p8); int main(void){ NRF52_SAADC pot(ANALOG_PIN_P+1, ANALOG_PIN_N+1); int16_t rawData; float voltage; char buffer[256]; sprintf(buffer, "Differential ADC inputs:"); epd.writeString(buffer, 30, 30, 0); sprintf(buffer, "AIN%d and AIN%d.", ANALOG_PIN_P, ANALOG_PIN_N); epd.writeString(buffer, 30, 50, 0); epd.writeFull(); while(1){ rawData = pot.read(); voltage = rawData*(3.6/512); sprintf(buffer, "ADC voltage is: %f", voltage); epd.writeString(buffer, 30, 70, 0); epd.write(); sprintf(buffer, "ADC voltage is: %f", voltage); epd.writeString(buffer, 30, 70, 1); epd.write(); } }