Muhammad Atir Sharif / Mbed 2 deprecated ticker

Dependencies:   mbed

Committer:
atir_sharif
Date:
Sat Jan 08 18:28:32 2022 +0000
Revision:
1:71b75f1d31ca
Parent:
0:06ea14e458e3
working

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kit1 0:06ea14e458e3 1 /*Program 5: Reads input voltage through the ADC, and transfers to PC terminal */
Kit1 0:06ea14e458e3 2 #include "mbed.h"
Kit1 0:06ea14e458e3 3
Kit1 0:06ea14e458e3 4 Serial pc(USBTX, USBRX); //enable serial port which links to USB
Kit1 0:06ea14e458e3 5 AnalogIn Ain(p20);
Kit1 0:06ea14e458e3 6 Timer t;
atir_sharif 1:71b75f1d31ca 7 float tim;
atir_sharif 1:71b75f1d31ca 8 char a[20];
atir_sharif 1:71b75f1d31ca 9 unsigned char count;
Kit1 0:06ea14e458e3 10
Kit1 0:06ea14e458e3 11 int main() {
atir_sharif 1:71b75f1d31ca 12 // pc.printf("ADC Data Values…\n\r"); //send an opening text message
Kit1 0:06ea14e458e3 13 while(1){
atir_sharif 1:71b75f1d31ca 14 pc.scanf("%s", &a);
Kit1 0:06ea14e458e3 15 t.start();
atir_sharif 1:71b75f1d31ca 16 pc.printf("%s \n\r", &a); //send the data to the terminal
Kit1 0:06ea14e458e3 17 t.stop();
atir_sharif 1:71b75f1d31ca 18 pc.printf("The time taken was %f seconds\n", t.read());
atir_sharif 1:71b75f1d31ca 19 tim = t.read();
atir_sharif 1:71b75f1d31ca 20 count = strlen(a);
atir_sharif 1:71b75f1d31ca 21 tim /= count;
atir_sharif 1:71b75f1d31ca 22 pc.printf("The time taken for one charater %f seconds\n", tim);
Kit1 0:06ea14e458e3 23 }
atir_sharif 1:71b75f1d31ca 24 }