homayoun mh
/
Arduino_DigitalReadSerial
Arduino_DigitalReadSerial sample code ported.
Diff: main.cpp
- Revision:
- 0:ca7d67d6dd20
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Sep 03 11:07:05 2014 +0000 @@ -0,0 +1,24 @@ +#include "mbed.h" + +Serial pc(SERIAL_TX, SERIAL_RX); +DigitalIn pushButton(USER_BUTTON); + +// 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() +{ + int buttonState = pushButton.read(); + pc.printf("%d\n", buttonState); + wait(1); +} + +int main() +{ + setup(); + while(1) loop(); +} \ No newline at end of file