Arduino_AnalogReadSerial sample code ported.

Dependencies:   mbed

main.cpp

Committer:
homayoun
Date:
2014-09-03
Revision:
0:c082a99a74f7

File content as of revision 0:c082a99a74f7:

#include "mbed.h"

Serial pc(SERIAL_TX, SERIAL_RX);
AnalogIn mySensor(A0);

// the setup routine runs once when you press reset:
void setup()
{
    pc.baud(9600);
}

// the loop routine runs over and over again forever:
void loop()
{
    uint16_t sensorValue = mySensor.read_u16(); // Converts and read the analog input value
    pc.printf("%d\n", sensorValue);
    wait(0.1);
}

int main()
{
    setup();
    while(1) loop();
}