Page 134 - ARM Based Microcontroller Projects Using MBED
P. 134
120 7. USING THE Mbed WITH SIMPLE PROJECTS
/******************************************************************
RANDOM COLOURED LED DISPLAY
===========================
In this project an RGB LED is connected to the Nucleo-F411RE
development board. The Red, Green, and Blue pins of the LED are
connected to GPIO pins PC_3, PC_4 and PC_5 respectively. The LED
displays random colours every 250ms.
Author: Dogan Ibrahim
Date : August 2018
File : RGB-2
*******************************************************************/
#include "mbed.h"
BusOut RGB(PC_3,PC_4,PC_5); // Group the LED pins
int main()
{
int Number;
while(1) // Do forever
{
Number = rand() % 5; // GEnerate a random number
RGB = Number; // Send the number to the LED
wait(0.25); // Wait 250ms
}
}
FIG. 7.64 Program listing.
7.16 PROJECT 13—7-SEGMENT LED DISPLAY
7.16.1 Description
In this project a single-digit 7-segment display is interfaced to the Nucleo-F411RE devel-
opment board. The display counts up every second from 0 to 9.
7.16.2 Aim
The aim of this project is to show how a 7-segment display can be interfaced to the Nucleo-
F411RE development board. Additionally, the project shows how to control such a display by
programming using Mbed.
7.16.3 Block Diagram
The block diagram of the project is shown in Fig. 7.65.