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 #include "SLCD.h" 00003 00004 SLCD slcd; 00005 AnalogOut DAC(PTE30); 00006 Serial pc(USBTX, USBRX); 00007 AnalogIn Ain1(PTB0); 00008 //AnalogIn Ain2(PTB1); 00009 00010 int main() 00011 { 00012 float ADCdata1; 00013 //float ADCdata2; 00014 float high_out = 0.999; 00015 float low_out = 0.0; 00016 float current_out = low_out; 00017 slcd.clear(); 00018 int state = 0; 00019 while (1) { 00020 ADCdata1=Ain1*3.3; 00021 //ADCdata2=Ain2*3.3; 00022 pc.printf("recv_in_1 %f \n\r",ADCdata1); 00023 //pc.printf("recv_in_2 %f \n\r",ADCdata2); 00024 pc.printf("state %i \n\r",state); 00025 pc.printf("output %f \n\r", current_out); 00026 wait (0.2); 00027 //3.8 -> 0.95 00028 if (state == 0 && ADCdata1 < 0.95) 00029 {current_out = high_out; 00030 state = 1;} 00031 //7.5 -> 1.785 00032 //7 -> 1.75 00033 if (state == 1 && ADCdata1 > 1.785) 00034 {current_out = low_out; 00035 state = 0;} 00036 DAC = current_out; 00037 slcd.printf("%1.3f", ADCdata1); 00038 } 00039 }
Generated on Sat Nov 19 2022 18:19:16 by
