microbit digital read test based on mbed SDK

Dependencies:   mbed

Committer:
coocox_paul
Date:
Mon Sep 19 03:38:40 2016 +0000
Revision:
0:9967b22d8665
first commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
coocox_paul 0:9967b22d8665 1 #include "mbed.h"
coocox_paul 0:9967b22d8665 2 /*
coocox_paul 0:9967b22d8665 3 * All the LEDs on the micro:bit are part of the LED Matrix,
coocox_paul 0:9967b22d8665 4 * In order to get simple blinking behaviour, we set column 0
coocox_paul 0:9967b22d8665 5 * to be permanently at ground. If you want to use the LEDs as
coocox_paul 0:9967b22d8665 6 * a screen, there is a display driver in the micro:bit 'DAL',
coocox_paul 0:9967b22d8665 7 */
coocox_paul 0:9967b22d8665 8 DigitalOut col0(P0_4, 0);
coocox_paul 0:9967b22d8665 9 //DigitalIn myswitch(P0_23);
coocox_paul 0:9967b22d8665 10 DigitalIn myswitch(P0_20);
coocox_paul 0:9967b22d8665 11
coocox_paul 0:9967b22d8665 12 DigitalOut myled(P0_13);
coocox_paul 0:9967b22d8665 13
coocox_paul 0:9967b22d8665 14 int main() {
coocox_paul 0:9967b22d8665 15 int v;
coocox_paul 0:9967b22d8665 16 myled = 1;
coocox_paul 0:9967b22d8665 17
coocox_paul 0:9967b22d8665 18 while(1) {
coocox_paul 0:9967b22d8665 19
coocox_paul 0:9967b22d8665 20
coocox_paul 0:9967b22d8665 21 v = myswitch.read();
coocox_paul 0:9967b22d8665 22
coocox_paul 0:9967b22d8665 23 if(v) {
coocox_paul 0:9967b22d8665 24 myled = !myled;
coocox_paul 0:9967b22d8665 25
coocox_paul 0:9967b22d8665 26 }
coocox_paul 0:9967b22d8665 27 wait(0.2);
coocox_paul 0:9967b22d8665 28 // myled = 1;
coocox_paul 0:9967b22d8665 29 // wait(0.2);
coocox_paul 0:9967b22d8665 30 // myled = 0;
coocox_paul 0:9967b22d8665 31 wait(0.2);
coocox_paul 0:9967b22d8665 32 }
coocox_paul 0:9967b22d8665 33 }