Page 131 - ARM Based Microcontroller Projects Using MBED
P. 131
7.15 PROJECT 12—RANDOM COLORED LED DISPLAY 117
else if(B == 0) // If B is pressed
{
if((RGB & 4) == 4) // If Blue is active
RGB = RGB & 3; // Turn OFF Blue
else // Otherwise
RGB = RGB | 4; // Turn ON Blue
while(B == 0); // Wait until released
}
}
}
FIG. 7.59, CONT’D
displayed then it is removed, otherwise it is displayed. This is repeated for all the three
buttons.
The Red, Green, and Blue LEDs are connected to PORT C in the following order:
Blue Green Red
The relationship between the RGB value and the colors that turn ON are as follows:
RGB Action
1 Turn ON Red
2 Turn ON Green
4 Turn ON Blue
6 Turn OFF Red
5 Turn OFF Green
3 Turn OFF Blue
7.15 PROJECT 12—RANDOM COLORED LED DISPLAY
7.15.1 Description
In this project an RGB LED is connected to the Nucleo-F411RE development board. The
three colors Red, Green, and Blue of the RGB are activated randomly every 250ms. The
net effect is that the LED displays different colors randomly.
7.15.2 Aim
The aim of this project is to show how an RGB LED can be activated randomly.