homayoun mh
/
Arduino_ReadAnalogVoltage
Arduino_ReadAnalogVoltage sample code ported.
main.cpp
- Committer:
- homayoun
- Date:
- 2014-09-03
- Revision:
- 0:f9483138df00
File content as of revision 0:f9483138df00:
#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 float voltage = sensorValue * (3.3 / 4095.0); pc.printf("%f\n", voltage); } int main() { setup(); while(1) loop(); }