Basic control of an RGB LED

Dependencies:   mbed

main.cpp

Committer:
MiskinPrj
Date:
2016-04-19
Revision:
0:b4aa4b3a7cee
Child:
1:56810f863198

File content as of revision 0:b4aa4b3a7cee:

/*********************************************************
*Renbed_RGB_Digital                                      *
*Author: Dan Argust                                      *
*                                                        *  
*A program that controls an RGB LED                      *
*********************************************************/

/* include the mbed library made by mbed.org that contains 
classes/functions designed to make programming mbed 
microcontrollers easier */
#include "mbed.h"

/* Set up 3 pins as digital out to control the colour
cathodes of the RGB LED */
DigitalOut Green(P0_22);
DigitalOut Red(P0_14);
DigitalOut Blue(P0_15);

int on = 0;
int off = 1;

int main()
{
    /* open a for loop with no parameters to start an infinite loop */
    for(;;){
        Red = off;
        Blue = off;
        Green = off;                
        wait_ms(1000);
        
        Red = on;
        wait_ms(1000);
        
        Red = off;
        Green = on;
        wait_ms(1000);
        
        Green = off;
        Blue = on;
        wait_ms(1000);
    }
}