Blinking All Leds using BusOut
Dependencies: mbed
main.cpp@1:f37612ceda88, 2015-10-07 (annotated)
- Committer:
- dwijaybane
- Date:
- Wed Oct 07 11:42:01 2015 +0000
- Revision:
- 1:f37612ceda88
- Parent:
- 0:f88d2b00a8e8
comments updated
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dwijaybane | 1:f37612ceda88 | 1 | #include "mbed.h" // Basic Library required for onchip peripherals |
dwijaybane | 0:f88d2b00a8e8 | 2 | |
dwijaybane | 1:f37612ceda88 | 3 | /* Create Objects */ |
dwijaybane | 1:f37612ceda88 | 4 | BusOut myleds(LED1, LED2, LED3, LED4); // Create a nibble of Digital Outputs named myleds |
dwijaybane | 1:f37612ceda88 | 5 | // So using single nibble one can easily access all listed bits |
dwijaybane | 0:f88d2b00a8e8 | 6 | |
dwijaybane | 1:f37612ceda88 | 7 | /* Main Program */ |
dwijaybane | 0:f88d2b00a8e8 | 8 | int main() { |
dwijaybane | 0:f88d2b00a8e8 | 9 | while(1) { |
dwijaybane | 1:f37612ceda88 | 10 | myleds = 0xF; // Glow All Leds |
dwijaybane | 1:f37612ceda88 | 11 | wait(0.5); // 500 ms delay |
dwijaybane | 1:f37612ceda88 | 12 | myleds = 0; // Turn off all leds |
dwijaybane | 1:f37612ceda88 | 13 | wait(0.5); // 500 ms delay |
dwijaybane | 0:f88d2b00a8e8 | 14 | } |
dwijaybane | 0:f88d2b00a8e8 | 15 | } |