EXP12

Dependencies:   mbed

Committer:
rx5
Date:
Thu Apr 21 04:50:12 2016 +0000
Revision:
0:bf343980193f
EXP12

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rx5 0:bf343980193f 1 #include "mbed.h"
rx5 0:bf343980193f 2 Serial pc(USBTX, USBRX); // Initlize UART on USB port of KL25Z with default Baud 9600
rx5 0:bf343980193f 3 AnalogIn ain(PTC2);
rx5 0:bf343980193f 4 int main()
rx5 0:bf343980193f 5 {
rx5 0:bf343980193f 6 float adc_value=0;
rx5 0:bf343980193f 7 // pc.baud(115200); // uncomment this line and update baudrate to cahnge baud rate from 9600 default
rx5 0:bf343980193f 8 pc.printf("\r\n"); // print startup message from new line on UART Terminal
rx5 0:bf343980193f 9 pc.printf("Experiment - 12\r\n"); // print startup message on UART Terminal
rx5 0:bf343980193f 10 pc.printf("ADC reading on UART Interface\r\n"); // print startup message on UART Terminal
rx5 0:bf343980193f 11 wait(3.0); // wait 3 second to show startup message
rx5 0:bf343980193f 12 while(1) // loop forever
rx5 0:bf343980193f 13 {
rx5 0:bf343980193f 14 adc_value = ain;
rx5 0:bf343980193f 15 pc.printf("ADC Reading in %% = %0.2f %% \t ADC Reading in mV = %0.2f mV\r\n",adc_value*100.0,adc_value*3300.0); // print ADC value in % and mV on UART Terminal
rx5 0:bf343980193f 16 wait(1.0); // Wait for 1 second
rx5 0:bf343980193f 17 }
rx5 0:bf343980193f 18
rx5 0:bf343980193f 19 }