Skip to content

Instantly share code, notes, and snippets.

@Xplorer001
Created March 25, 2016 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xplorer001/d46092fcad54a3b628f0 to your computer and use it in GitHub Desktop.
Save Xplorer001/d46092fcad54a3b628f0 to your computer and use it in GitHub Desktop.
#include "adc.h"
#include "uart.h"
int main()
{
int adcValue;
float volt;
ADC_Init(); /* Initialize the ADC module */
UART_Init(9600); /* Initialize UART at 9600 baud rate */
while(1)
{
adcValue = ADC_GetAdcValue(0); // Read the ADC value of channel zero
volt = (adcValue*5.00)/1023; //10bit resolution, 5vReference
UART_Printf("ADC0 Value:%4d Equivalent Voltage:%f\n\r",adcValue,volt); // Send the value on UART
}
return (0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment