ad test

Dependencies:   mbed

main.cpp

Committer:
pedro_C
Date:
2016-10-28
Revision:
3:c8e6635e6f4b
Parent:
1:0490a15c76e4

File content as of revision 3:c8e6635e6f4b:

#include "mbed.h"

AnalogIn analog_1(PA_3);
AnalogIn analog_2(PC_0);
AnalogIn analog_3(PC_3);
AnalogIn analog_4(PF_3);
AnalogIn analog_5(PF_10);
AnalogIn analog_6(PA_7);
AnalogIn analog_7(PF_8);
AnalogIn analog_8(PF_7);
AnalogIn analog_9(PF_9);

Serial pc(USBTX,USBRX);

Timer t;


int main()
{
    t.start();
    pc.baud(115200);
    float meas;

    // pc.printf("\nAnalogIn example\n");

    while(1) {
        pc.printf("%f seconds\t", t.read());
        meas = analog_1.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
        meas = meas * 3300; // Change the value to be in the 0 to 3300 range
        pc.printf("%.0f mV, \t", meas);

        meas = analog_2.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
        meas = meas * 3300; // Change the value to be in the 0 to 3300 range
        pc.printf("%.0f mV, \t", meas);

        meas = analog_3.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
        meas = meas * 3300; // Change the value to be in the 0 to 3300 range
        pc.printf("%.0f mV, \t", meas);

        meas = analog_4.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
        meas = meas * 3300; // Change the value to be in the 0 to 3300 range
        pc.printf("%.0f mV, \t", meas);

        meas = analog_5.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
        meas = meas * 3300; // Change the value to be in the 0 to 3300 range
        pc.printf("%.0f mV, \t", meas);

        meas = analog_6.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
        meas = meas * 3300; // Change the value to be in the 0 to 3300 range
        pc.printf("%.0f mV, \t\t", meas);

        meas = analog_7.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
        meas = meas * 3300; // Change the value to be in the 0 to 3300 range
        pc.printf("%.0f mV, \t", meas);

        meas = analog_8.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
        meas = meas * 3300; // Change the value to be in the 0 to 3300 range
        pc.printf("%.0f mV, \t", meas);

        meas = analog_9.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
        meas = meas * 3300; // Change the value to be in the 0 to 3300 range
        pc.printf("%.0f mV, \n", meas);

        wait_ms(20);
    }
}