not yet completed

Dependencies:   FatFileSystem MSCFileSystem TextLCD mbed

Fork of TextLCD_HelloWorld by Simon Ford

Revision:
3:8228ff1c1999
Parent:
2:ad0b044d0a10
Child:
4:eda6dbfa1d1c
--- a/main.cpp	Sat Dec 04 11:31:07 2010 +0000
+++ b/main.cpp	Wed May 04 06:34:59 2016 +0000
@@ -1,10 +1,63 @@
-// Hello World! for the TextLCD
-
 #include "mbed.h"
 #include "TextLCD.h"
+#include "string"
+#include "MSCFileSystem.h"
 
-TextLCD lcd(p15, p16, p17, p18, p19, p20); // rs, e, d4-d7
+TextLCD lcd(p15, p16, p10, p11, p12, p13); // rs, e, d4-d7 ;LCD configuration
+
+LocalFileSystem fs("fs");
+
+AnalogOut   aout(p18);                                      //DAC
+AnalogIn    ain(p17);                                       //ADC current read
+DigitalIn   pb(p9);                                         //Switch
+DigitalOut  dout(LED1);                             
+DigitalOut  trig(p5);                                       //
+DigitalOut  trigstop(p6);                                   //
+int pbb;
+
+float mini = 0.4f,maxi = 1.2f,stepsize = 0.005f,highV=0,highC=0;
+float pulsedur=0.5,step,sample,width=0.2,current,pulseamplitude=0.1;
+
+void lcdprintnum(float number);
 
 int main() {
-    lcd.printf("Hello World!\n");
+    lcd.cls();
+    pb.mode(PullDown);
+    
+    while(1){
+        pbb=pb;
+        trig=0;
+        trigstop=0;
+        lcd.locate(0,0);  
+        lcd.printf("DEVICE READY...");
+        
+        if(pbb==1){
+            FILE *fp = fopen("/fs/test.csv","w");
+        
+            lcd.cls();
+            wait(0.1);
+        
+            lcd.locate(0,0);  
+            lcd.printf("ScanRate:0.01V/s ");
+                
+            for(float i = (mini/3.3); i < (maxi/3.3); i += (stepsize/3.3f)) {
+                aout=(i - (pulseamplitude/3.3));                            //base voltage
+                wait(pulsedur-width);                                      //base voltage duration, sample 1 here
+                aout=i;                                                    //pulse voltage 
+                lcd.locate(0,1); 
+                lcdprintnum(aout.read()*3.3);
+                lcd.printf(" V");
+                wait(width);                                             //high pulse duration ; pulse = i
+            }
+            aout=0;  
+            lcd.cls();   
+        }
+    }
 }
+
+void lcdprintnum(float number){                     //to display number on lcd
+    char aoutstring[10];  
+    sprintf(aoutstring,"%.4f",(number));          //convert from float to string to display
+    lcd.printf(aoutstring);           
+}
+                
\ No newline at end of file