Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of microbit_blinky by
Revision 2:83f7d8e01b11, committed 2018-09-20
- Comitter:
- f3d
- Date:
- Thu Sep 20 10:58:30 2018 +0000
- Parent:
- 1:0b38b848a5f0
- Commit message:
- Revised version of code
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- 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
}
}
