Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "mbed.h" 00002 00003 #define kRED 4 00004 #define kYELLOW 2 00005 #define kGREEN 1 00006 00007 //Global objects 00008 BusOut binaryOutput(D5, D6, D7); //Outputs as an integer 00009 00010 DigitalIn SW1(D3); 00011 DigitalIn SW2(D4); 00012 00013 AnalogIn AIN(A0); 00014 float fVin = 0.0; 00015 00016 //Main function 00017 int main() { 00018 00019 00020 while(1) { 00021 00022 //Read ADC 00023 fVin = AIN; 00024 00025 //Write to terminal 00026 printf("Analog input = %6.4f\n", fVin); //3 decimal places, fieldwidth=5 00027 00028 if (fVin < 0.5f) { 00029 binaryOutput = kGREEN; 00030 } else { 00031 binaryOutput = kRED; 00032 } 00033 00034 //Wait 00035 wait(0.5); 00036 00037 } //end while(1) 00038 } //end main
Generated on Thu Jul 14 2022 02:53:16 by
1.7.2