SAADC differential input setup. With EPD display.

Dependencies:   GDEP015OC1 acn_nrf52_saadc adc52832_common

main.cpp

Committer:
jurica238814
Date:
2017-09-28
Revision:
1:41e296b93414
Parent:
0:04520242cfef
Child:
2:49dab8d9637a

File content as of revision 1:41e296b93414:

/*
 * 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"
 

#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



int main(void){
    int16_t rawData;
    float voltage;
    uint16_t delay = 500;
    
    NRF52_SAADC pot(5, 6);
    
    while(1){
        rawData = pot.read();
        voltage = rawData*(3.6/512);
        SEND("Voltage on differential ADC input is: %f\r\n", voltage);
        wait_ms(delay);
    }
}