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.
Dependencies: mbed
main.cpp
00001 #include "mbed.h" 00002 00003 #define kRED (1 << 2) //4 00004 #define kYELLOW (1 << 1) //2 00005 #define kGREEN (1 << 0) //1 00006 #define kALL (kRED | kYELLOW | kGREEN) 00007 00008 //Global objects 00009 BusOut binaryOutput(D5, D6, D7); 00010 DigitalIn SW1(D3); 00011 DigitalIn SW2(D4); 00012 00013 AnalogIn POT_ADC_In(A0); 00014 AnalogIn LDD_ADC_In(A1); 00015 00016 float fPOT, fLDR = 0.0; 00017 00018 //Main function 00019 int main() { 00020 00021 while(1) { 00022 00023 //Read ADC 00024 fPOT = POT_ADC_In; 00025 fLDR = LDD_ADC_In; 00026 00027 //TODO: 00028 //Calculate the average of both fPOT and fLDR, then write to the terminal 00029 00030 //Write to terminal 00031 printf("POT = %6.4f\tLDR = %6.4f\n", fPOT, fLDR); 00032 00033 if (fLDR > fPOT) { 00034 binaryOutput = 0; //Binary 000 00035 } else { 00036 binaryOutput = kALL; //Binary 111 00037 } 00038 00039 //Wait 00040 wait(0.1); 00041 00042 } //end while(1) 00043 } //end main
Generated on Fri Aug 26 2022 11:05:10 by
1.7.2