Thiago Lima / Mbed 2 deprecated RGB_leds

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 // The following sequence is presented:
00004 // GREEN   - 1 second
00005 // BLUE    - 1 second
00006 // RED     - 1 second
00007 // WHITE   - 1 second
00008 // ALL OFF - 4 seconds
00009 
00010 
00011 #define OFF         1
00012 #define ON          0
00013 #define TIME        1
00014 
00015 DigitalOut myled_blue(LED1);
00016 DigitalOut myled_green(LED2);
00017 DigitalOut myled_red(LED3);
00018 void all_off(void);
00019 void all_on(void);
00020 
00021 int main()
00022 {
00023     while(1) {
00024         all_off();
00025         myled_green = ON;
00026         wait(TIME);
00027         all_off();
00028 
00029         myled_blue = ON;
00030         wait(TIME);
00031         all_off();
00032 
00033         myled_red = ON;
00034         wait(TIME);
00035         all_off();
00036 
00037         all_on(); //WHITE
00038         wait(TIME);
00039         all_off();
00040 
00041         wait(TIME*4);
00042     }
00043 }
00044 
00045 void all_off(void)
00046 {
00047     myled_green = OFF;
00048     myled_blue  = OFF;
00049     myled_red   = OFF;
00050 }
00051 
00052 void all_on(void)
00053 {
00054     myled_green = ON;
00055     myled_blue  = ON;
00056     myled_red   = ON;
00057 }