Muhammad Atir Sharif / Mbed 2 deprecated ticker

Dependencies:   mbed

Revision:
1:71b75f1d31ca
Parent:
0:06ea14e458e3
--- a/main.cpp	Sun Sep 01 10:33:17 2013 +0000
+++ b/main.cpp	Sat Jan 08 18:28:32 2022 +0000
@@ -4,19 +4,21 @@
 Serial pc(USBTX, USBRX); //enable serial port which links to USB
 AnalogIn Ain(p20);
 Timer t;
-float ADCdata;
+float tim;
+char a[20];
+unsigned char count;
 
 int main() {
-    pc.printf("ADC Data Values…\n\r"); //send an opening text message 
+//    pc.printf("ADC Data Values…\n\r"); //send an opening text message 
     while(1){
+        pc.scanf("%s", &a);
         t.start();
-         for (int i=0;i<=9;i++) {
-            ADCdata=ADCdata+Ain*3.3; //sum 10 samples
-        }
-        ADCdata=ADCdata/10; //divide by 10
-        wait(0.5);
-        pc.printf("%1.3f \n\r",ADCdata); //send the data to the terminal
+        pc.printf("%s \n\r", &a); //send the data to the terminal
         t.stop();
-        printf("The time taken was %f seconds\n", t.read());
+        pc.printf("The time taken was %f seconds\n", t.read());
+        tim = t.read();
+        count = strlen(a);
+        tim /= count;
+        pc.printf("The time taken for one charater %f seconds\n", tim);
     }
-}
+}
\ No newline at end of file