Arduino_DigitalReadSerial sample code ported.

Dependencies:   mbed

Committer:
homayoun
Date:
Wed Sep 03 11:07:05 2014 +0000
Revision:
0:ca7d67d6dd20
Arduino_DigitalReadSerial

Who changed what in which revision?

UserRevisionLine numberNew contents of line
homayoun 0:ca7d67d6dd20 1 #include "mbed.h"
homayoun 0:ca7d67d6dd20 2
homayoun 0:ca7d67d6dd20 3 Serial pc(SERIAL_TX, SERIAL_RX);
homayoun 0:ca7d67d6dd20 4 DigitalIn pushButton(USER_BUTTON);
homayoun 0:ca7d67d6dd20 5
homayoun 0:ca7d67d6dd20 6 // the setup routine runs once when you press reset:
homayoun 0:ca7d67d6dd20 7 void setup()
homayoun 0:ca7d67d6dd20 8 {
homayoun 0:ca7d67d6dd20 9 pc.baud(9600);
homayoun 0:ca7d67d6dd20 10 }
homayoun 0:ca7d67d6dd20 11
homayoun 0:ca7d67d6dd20 12 // the loop routine runs over and over again forever:
homayoun 0:ca7d67d6dd20 13 void loop()
homayoun 0:ca7d67d6dd20 14 {
homayoun 0:ca7d67d6dd20 15 int buttonState = pushButton.read();
homayoun 0:ca7d67d6dd20 16 pc.printf("%d\n", buttonState);
homayoun 0:ca7d67d6dd20 17 wait(1);
homayoun 0:ca7d67d6dd20 18 }
homayoun 0:ca7d67d6dd20 19
homayoun 0:ca7d67d6dd20 20 int main()
homayoun 0:ca7d67d6dd20 21 {
homayoun 0:ca7d67d6dd20 22 setup();
homayoun 0:ca7d67d6dd20 23 while(1) loop();
homayoun 0:ca7d67d6dd20 24 }