Miskin Project
/
Renbed_RGB_Digital
Basic control of an RGB LED
Diff: main.cpp
- Revision:
- 0:b4aa4b3a7cee
- Child:
- 1:56810f863198
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Apr 19 10:12:23 2016 +0000 @@ -0,0 +1,44 @@ +/********************************************************* +*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); + } +} + + \ No newline at end of file