Basic control of an RGB LED

Dependencies:   mbed

main.cpp

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

File content as of revision 1:56810f863198:

/*********************************************************
*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 Red(P1_24);
DigitalOut Green(P1_26);
DigitalOut Blue(P0_19);

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);
    }
}