Nicholas Outram / Mbed OS Task411
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 //Global objects
00004 BusOut binaryOutput(D5, D6, D7);    //Outputs as an integer
00005 
00006 DigitalIn SW1(D3);
00007 DigitalIn SW2(D4);
00008 
00009 AnalogIn AIN(A0);
00010 float fVin = 0.0;
00011 
00012 //Main function
00013 int main() {
00014 
00015 
00016     while(1) {
00017         
00018         //Read ADC         
00019         fVin = AIN;
00020         
00021         //Write to terminal
00022         printf("Analog input = %6.4f\n", fVin); //3 decimal places, fieldwidth=5
00023         
00024         //Wait
00025         wait(0.5);
00026             
00027     } //end while(1)
00028 } //end main