Lesson 4 RGB Ambient Light Show

In urban nightscapes, stage performances, or storefront displays, vibrant and colorful lighting effects not only attract attention but also convey information and emotions. This lesson focuses on the bottom RGB ambient lights of the Maqueen Lite V5, using programming to create various dynamic lighting effects such as color transitions, running lights, and rainbow rotations. It also explores how to link lighting with the movement states of the robot car, crafting a light show that combines visual aesthetics with logical control.
Through this lesson, students will further master programming methods for RGB light strips, understand the role of variables in coding, and enhance their ability to synchronize lighting with motion control.

Task Objective

This lesson aims to guide learners to programmatically control the bottom RGB ambient lights of the Maqueen Lite V5, achieving dynamic lighting effects such as color transitions, running lights, and breathing colors. By integrating the robot car’s forward and backward movements, learners will create intelligent synchronization between lighting and motion states.

Knowledge Points

1.Master the basic control methods of the bottom RGB ambient lights.
2.Learn to use variables to manage the light strip objects.
3.Implement various dynamic lighting effects.
4.Understand the logic of linking lighting with motion states.

Materials List

HARDWARE LIST
1 Maqueen Lite V5
1 micro:bit
1 Micro USB Cable

Software

Mind+ Programming Software x1
Download link: https://mindplus.cc/

Practical Exercise

This lesson’s practice focuses on the bottom RGB ambient lights of the Maqueen Lite V5, progressing from basic color control to complex dynamic effects to gradually master programming techniques. It is divided into three tasks:
Task 1: Color Switching
Implement the ambient lights to cycle through multiple colors continuously.
Task 2: Rotating Color Lights
Control the ambient lights to light up sequentially in a running light pattern, creating a continuous flowing visual effect.
Task 3: Robot Car Light Show
Display breathing light effects when the car moves forward, and color switching when it moves backward, achieving synchronized changes between lighting and motion.


Task 1: Color Switching

1.Programming

(1)Light Strip Display
Within a repeated loop, set the RGB lights to show red and pause for 1 second after displaying. Since the RGB lights support 10 different color options, you can select different colors as needed to create a variety of lighting effects.

(2)Multi-Color Cycle
Continuing in the loop, sequentially set the "strip" light strip to red, orange, yellow, green, blue, white, purple, and other colors, each lasting for 1 second. This way, the ambient lights will cycle through colors in order, creating a dynamic and colorful visual effect.

2.Program Execution

After the program is successfully uploaded to the device, the bottom ambient lights of the Maqueen robot will flash sequentially in the order of red, orange, yellow, green, blue, white, and purple, with each color flashing for 1 second.

Task 2: Rotating Color Lights

1.Programming

(1)Set the color of LED 0 to violet
We set the RGB LED at position 0 (RGB0) to violet, lighting up the first LED with a violet color.

(2)Setting the Running Light Effect
After setting the RGB0 LED to violet, to achieve a running light effect, you need to use a looped shift command. This command shifts the light color by one position in each cycle, followed by a 100-millisecond delay. As a result, the violet light will gradually move from RGB0 to RGB3, creating a dynamic running light effect.


2.Program Execution

After the program is successfully uploaded, the RGB0 LED at the bottom of the robot car will light up violet first. Then, the light will shift one position to the right every 100 milliseconds, continuously cycling among the 4 LEDs to create a cool running light dynamic effect.


Task 3: Robot Car Light Show

1.Programming

(1)Control the robot car to move forward and display breathing light effect
First, set the 4 RGB LEDs to display violet and create a variable named "light", initializing it to 0. After initialization, inside the loop, set the robot car to move forward at a speed of 60.

To create a breathing light effect for the RGB LEDs, we use nested loop statements. A loop that repeats 51 times gradually adjusts the brightness of the RGB lights, achieving the smooth breathing effect.

(2)Control the robot car to move backward and display multi-color switching effect
Within the outer infinite loop, set the motors to reverse so the car moves backward. Reuse the color-switching code from Task 1 to make the light strip sequentially display red, yellow, green, blue, and purple, each color lasting 200 milliseconds, achieving synchronized changes between the car’s movement and lighting.


2.Program Execution

After the program is successfully uploaded, starting the robot car will result in the following behavior:
- When the car moves forward, the bottom RGB lights gradually brighten and dim, creating a breathing light effect.
- When the car moves backward, the light strip cycles through red → yellow → green → blue → purple in sequence, with 200ms intervals, producing a dynamic color-changing effect.

Knowledge Corner

1.Understanding Variables

What is a variable? To make it easier to understand, we can think of a variable as a box. Assigning a value to a variable is like putting something into this box. Variables can be reassigned multiple times, meaning the contents of the box can be taken out and replaced with something else.

This program repeatedly assigns values to the variable "light". The first assignment is like putting the number 255 into the empty box named "light", so the value of "light" becomes 255. During the second assignment, the number 255 is taken out and replaced with 250, making the value of "light" equal to 250.


The advantages of variables are that they make programs cleaner and easier to manage; they can be reused repeatedly, improving efficiency; and they allow the content inside to change dynamically based on different situations.
When writing programs, learning to use variables is like giving your program a “memory.” Variables can store, modify, and retrieve information, making them a fundamental and essential concept in programming.


2.Learning the Commands


Challenge Yourself

In this lesson, everyone has mastered the control of the robot car’s bottom RGB ambient lights and completed a series of wonderful light shows. Now, you can try designing unique lighting effects for the car’s left and right turns. Refer to the lesson code and add your own creative ideas—for example, display a running light effect flowing from left to right when turning left, and from right to left when turning right.

icon 2. program.zip 498KB Download(0)
License
All Rights
Reserved
licensBg
0