IoT 2018

Dependencies:   mbed

Fork of microbit_blinky by BBC

Revision:
2:83f7d8e01b11
Parent:
1:0b38b848a5f0
--- a/main.cpp	Thu Sep 20 09:17:38 2018 +0000
+++ b/main.cpp	Thu Sep 20 10:58:30 2018 +0000
@@ -4,9 +4,6 @@
 // Pin labelled "0" on edge connector is in fact connected to P0_3 
 volatile uint32_t * P0OUT = (uint32_t *)0x50000504;
 volatile uint32_t * P0DIR = (uint32_t *)0x50000514;
-volatile uint32_t * P0IN  = (uint32_t *)0x50000510;
-volatile uint32_t * P0CONF  = (uint32_t *)(0x50000700);
-
 void dly(volatile uint32_t len)
 {
     // "volatile" modifier is necessary here 
@@ -14,22 +11,13 @@
     // this software delay to nothing
     while(len--);
 }
-int ButtonAPressed()
-{
-    // Button A pulls down so bit is zero when pressed.
-    if ((*P0IN & (1 << 17))==0)    
-        return 1;
-    else
-        return 0;
-}
 int main() {
     
-    *P0DIR = (1 << 3);    
-    P0CONF[17] = 0;  // On power up, input buffer is not connected so must do this
-    while(1) {                 
-        if (ButtonAPressed()) 
-            *P0OUT = (1 << 3);       
-        else
-            *P0OUT = 0;                      
+    *P0DIR = (1 << 3);    // Make P0 Bit 3 (labelled 0 on breakout board) an output
+    while(1) {                  
+        *P0OUT = (1 << 3); // Make P0 Bit 3 a '1' (turns on the LED)    
+        dly(1000000);      // wait a while
+        *P0OUT = 0;        // LED off
+        dly(1000000);      // Wait a while
     }
 }