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: FatFileSystem MSCFileSystem TextLCD mbed
Fork of TextLCD_HelloWorld by
main.cpp
00001 #include "mbed.h" 00002 #include "TextLCD.h" 00003 #include "string" 00004 //#include "MSCFileSystem.h" 00005 00006 TextLCD lcd(p15, p16, p10, p11, p12, p13); // rs, e, d4-d7 ;LCD configuration 00007 00008 LocalFileSystem fs("fs"); 00009 00010 AnalogOut aout(p18); //DAC 00011 AnalogIn ain(p17); //ADC current read 00012 DigitalIn pb(p9); //Switch 00013 DigitalOut dout(LED1); 00014 DigitalOut trig(p5); // 00015 DigitalOut trigstop(p6); // 00016 DigitalOut trigstart(p7); // 00017 int pbb; 00018 00019 float mini = 0.1f,maxi = 1.2f,stepsize = 0.005f,highV=0,highC=0,readd; 00020 float pulsedur=0.5,step,sample,width=0.25,current,pulseamplitude=0.1; 00021 00022 void lcdprintnum(float number); 00023 00024 int main() { 00025 lcd.cls(); 00026 pb.mode(PullDown); 00027 00028 while(1){ 00029 pbb=pb; 00030 trig=0; 00031 trigstop=0; 00032 lcd.locate(0,0); 00033 lcd.printf("DEVICE READY..."); 00034 00035 if(pbb==1){ 00036 FILE *fp = fopen("/fs/test.csv","w"); 00037 00038 lcd.cls(); 00039 wait(0.1); 00040 00041 lcd.locate(0,0); 00042 lcd.printf("ScanRate:0.01V/s "); 00043 00044 00045 for(float i = (mini/3.3); i < (maxi/3.3); i += (stepsize/3.3f)) { 00046 aout=(i - (pulseamplitude/3.3)); 00047 trigstart=1; 00048 trigstart=0; 00049 trig=0; 00050 wait(pulsedur-width); //base voltage duration, sample 1 here 00051 00052 if(i>=1.19/3.3){ 00053 trigstop=1; 00054 } 00055 00056 aout=i; //pulse voltage 00057 lcd.locate(0,1); 00058 lcdprintnum(aout.read()*3.3); 00059 lcd.printf(" V"); 00060 trigstart=1; 00061 trigstart=0; 00062 trig=1; 00063 wait(width); 00064 00065 // readd=3.3f*aout.read(); 00066 00067 // if(readd>highC){ 00068 // highC=readd; 00069 // } 00070 00071 00072 //high pulse duration ; pulse = i 00073 } 00074 aout=0; 00075 lcd.cls(); 00076 lcdprintnum(readd); 00077 00078 wait(2); 00079 00080 } 00081 } 00082 } 00083 00084 void lcdprintnum(float number){ //to display number on lcd 00085 char aoutstring[10]; 00086 sprintf(aoutstring,"%.4f",(number)); //convert from float to string to display 00087 lcd.printf(aoutstring); 00088 } 00089
Generated on Wed Jul 13 2022 19:00:43 by
1.7.2
