Expansion：Rainbow LED Ligth Bar Module
7. Expansion：Rainbow LED Ligth Bar Module#
It comes with 8 Rainbow full color LEDs. You can update it to a car with auto-headlights and rainbow lights.
Input voltage 3V~5V，driving directly by micro:bit.
Standard 3 line GVS port, occupying only one I/O port.
8 small LEDs, power saving and energy saving.
Each led can be programmed seperately with RGB color.
|Name||Ring:bit Car v2 ligth bar|
|Working Voltage||DC 3-5V|
|Connections||Ring:bit Car dedicated pin ports||Fixed with scews|
7.4. Outlook and Dimensions#
7.5. Quick to Start#
First, insert this module to the baseboard of the Ring:bit car V2,Fix with the screws,Completed.
Preparation for programming: Introduction
# Import the modules we need: import board from ringbit import * from digitalio import * from neopixel_write import * from time import * from random import * # Set the pins and directions of the wheels and the light bar ringbit = Ringbit(board.P1, board.P2) pin = DigitalInOut(board.P0) pin.direction = Direction.OUTPUT # Set the speed of the car ringbit.set_speed(100, 100) # While true, change the color of the light bar while True: rings =  for i in range(30): rings.append(randint(0, 255)) neopixel_write(pin, bytearray(rings)) sleep(0.1)
Details of the Program:#
1.Import the modules that we need.
board is the common container, and you can connect the pins you’d like to use through it;
ringbit module contains classes and functions for Ring:bit smart car operations, the
time module contains functions for time operations, the
digitalio module contains classes for basic digital IO access, the
neopixel_write module contains functions for strip operations, and the
random module contains functions that can return random numbers
import board from ringbit import * from digitalio import * from neopixel_write import * from time import * from random import *
2.Set the pins of the servos and the pins and directions of the breakout board.
ringbit = Ringbit(board.P1, board.P2) pin = DigitalInOut(board.P0) pin.direction = Direction.OUTPUT
3.Set the speed of the car
4.While true, change the RGB value of each LED in the light bar to detect if the A\B button is pressed to set the speed of the left and right wheels of the Ring:bit smart car
while True: rings =  for i in range(30): rings.append(randint(0, 255)) neopixel_write(pin, bytearray(rings)) sleep(0.1)
The two lights on the bottom of the Ring:bit car as well as the light bar change colour randomly to give a colourful effect; press A to move the car forward at full speed, press B to stop the car.