Arduino_Button sample code ported.

Dependencies:   mbed

Fork of InterruptIn_HelloWorld by mbed official

Committer:
homayoun
Date:
Wed Sep 03 11:01:07 2014 +0000
Revision:
1:45300b60edf4
Parent:
0:7a20a6aa1f5e
Arduino_Button

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 0:7a20a6aa1f5e 1 #include "mbed.h"
homayoun 1:45300b60edf4 2
homayoun 1:45300b60edf4 3 DigitalIn button(USER_BUTTON);
mbed_official 0:7a20a6aa1f5e 4 DigitalOut led(LED1);
homayoun 1:45300b60edf4 5
homayoun 1:45300b60edf4 6 void setup()
homayoun 1:45300b60edf4 7 {
homayoun 1:45300b60edf4 8 button.mode(PullUp);
mbed_official 0:7a20a6aa1f5e 9 }
homayoun 1:45300b60edf4 10
homayoun 1:45300b60edf4 11 void loop()
homayoun 1:45300b60edf4 12 {
homayoun 1:45300b60edf4 13 if (button == 0) {
homayoun 1:45300b60edf4 14 // turn LED on:
homayoun 1:45300b60edf4 15 led = 1;
homayoun 1:45300b60edf4 16 } else {
homayoun 1:45300b60edf4 17 // turn LED off:
homayoun 1:45300b60edf4 18 led = 0;
mbed_official 0:7a20a6aa1f5e 19 }
homayoun 1:45300b60edf4 20 }
homayoun 1:45300b60edf4 21
homayoun 1:45300b60edf4 22 int main()
homayoun 1:45300b60edf4 23 {
homayoun 1:45300b60edf4 24 setup();
homayoun 1:45300b60edf4 25 while(1) loop();
mbed_official 0:7a20a6aa1f5e 26 }