homayoun mh
/
Arduino_AnalogReadSerial
Arduino_AnalogReadSerial sample code ported.
Revision 0:c082a99a74f7, committed 2014-09-03
- Comitter:
- homayoun
- Date:
- Wed Sep 03 10:22:21 2014 +0000
- Commit message:
- Arduino_AnalogReadSerial
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r c082a99a74f7 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Sep 03 10:22:21 2014 +0000 @@ -0,0 +1,24 @@ +#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(); +} \ No newline at end of file
diff -r 000000000000 -r c082a99a74f7 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Sep 03 10:22:21 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9327015d4013 \ No newline at end of file