Basic control of an RGB LED
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 /********************************************************* 00002 *Renbed_RGB_Digital * 00003 *Author: Elijah Orr & Dan Argust * 00004 * * 00005 *A program that controls an RGB LED * 00006 *********************************************************/ 00007 00008 /* include the mbed library made by mbed.org that contains 00009 classes/functions designed to make programming mbed 00010 microcontrollers easier */ 00011 #include "mbed.h" 00012 00013 /* Set up 3 pins as digital out to control the colour 00014 cathodes of the RGB LED */ 00015 DigitalOut Red(P1_24); 00016 DigitalOut Green(P1_26); 00017 DigitalOut Blue(P0_19); 00018 00019 /* Set the on and off states of the lights */ 00020 const int on = 0; 00021 const int off = 1; 00022 00023 int main() 00024 { 00025 /* open a for loop with no parameters to start an infinite loop */ 00026 for(;;){ 00027 Red = off; 00028 Blue = off; 00029 Green = off; 00030 wait_ms(1000); 00031 00032 Red = on; 00033 wait_ms(1000); 00034 00035 Red = off; 00036 Green = on; 00037 wait_ms(1000); 00038 00039 Green = off; 00040 Blue = on; 00041 wait_ms(1000); 00042 } 00043 } 00044 00045
Generated on Fri Jul 15 2022 18:22:15 by
1.7.2