The Pinay Homeschooler
  • HOME
  • TODDLER
  • PRESCHOOL
  • KINDERGARTEN
  • GRADE SCHOOL
  • SHOP
  • FREE PRINTABLES
  • ABOUT ME

Coding Lessons for Kids RGB Light Programming

Saturday, January 4, 2020

This is our second coding lesson using Micro:bit and DFRobot Maqueen. In case you missed the first lesson you can check it out here, Coding Lessons for Kids Using BBC Microbit Robot Car.

In this lesson we explore another device, programmable colored LED lights, integrated in the robot car. We will also introduce the concept of "FUNCTIONS" in programming and how to do it via the MakeCode program editor.

Coding Lessons for Kids RGB Light Programming

List of Materials

  • DFROBOT MAQUEEN
  • Micro USB Cable
  • 3 AAA Battery
  • Laptop or PC to access Microbit Makecode Visual Programming IDE

Learning Goals

  • Learn how to access and control the NeoPixel RGB Light Strip
  • Learn how to produce different colors of light by adjusting the brightness of each color component: RED, GREEN, BLUE of the RGB Light
  • Learn how to import and reuse Projects by loading *.hex files
  • Learn how to create and group repetitive codes into a function
  • Learn how to display a number on the 5x5 LED matrix of Micro:bit
  • Learn how to use the Makecode editor simulator

NeoPixel RGB Light Strip

The Maqueen robot car has 4 on-board RGB LED lights under its circuit board that can be programmed to take on different colors. RGB is an acronym for RED - GREEN - BLUE, the color components that control the output color of the LED light.

The image below is from DFRobot Maqueen Wiki. NeoPixel RGB Light Strip
The 4 RGB LED lights are connected to the Micro:bit controller board via the output pin P15.

The images used below are from BBC micro:bit MicroPython documentation and from components101.com.

Microbit RGB Light Connection
In order to control or program the RGB Light Strip we need to assign it to a variable at the beginning of the program.

RGB Light Initialization
During program runtime, the RGB Light variable will be assigned with the appropriate brightness for each component color: red, green, and blue.

RGB Light Programming
Each color component can be programmed with a value from 0 to 255 that represents the amount of brightness or intensity of the color. Zero represents that the color component is OFF and 255 represents the maximum brightness of the color component.

At the end of every lesson the student should fill-up the appropriate output color in the table below (The FREE printable at the end of the post contains a copy of this table):

RGB Map Table

LESSON 1: Generating Colored Light

The detailed tasks of this lesson are detailed in the FREE printable that can be downloaded at the end of the post. I will just give a summary of the lesson in this post.

I've also prepared a video which beginner students can follow instead of writing the program on their own. You can access the video here.


In LESSON 1, the student is tasked to write a program that will switch between OFF, BLUE, GREEN, and RED colored light when BUTTON B is pressed.

The following variables need to be created and initialized at the start of the program: CURRENT_COLOR, RED, GREEN, BLUE, and RGB_LIGHT.

RGB_LIGHT is a special variable that needs to be associated with the RGB Light strip device on board the robot car.

LESSON 2: Creating Functions

Similar to LESSON 1, the detailed tasks of this lesson are detailed in the FREE printable that can be downloaded at the end of the post and I will just give a summary of the lesson in this post.

The main goal of this lesson is to introduce the concept of functions and how to implement them in the Makecode block programming editor. This lesson also touches on the method of reusing or importing previously created projects. Finally, it introduces the simulator embedded in the Makecode editor. The lesson starts by instructing the student to import the project (.hex) created in LESSON 1. The video here will guide the student on how to import existing projects. If you skipped LESSON 1 you can also download and use this solution project here as a starting point for this part of the lesson.

The next part of the lesson introduces the simulator (LEFT SIDE OF THE MAKECODE EDITOR) embedded in the MakeCode editor.

MakeCode Simulator
The last part of LESSON 2 instructs the student to group the repetitive code created in LESSON 1 into a function. Please see the video here for an example on how to go about this part of the lesson.

FREE LESSON PRINTABLE AND HEX SOURCE FILES

Finally, to help you in conducting the lessons I've provided a free printable below and links to the source files of the completed programs.
  • Coding Lessons for Kids RGB Light Programming PRINTABLE
  • LESSON 1: Generating Colored Light SOLUTION HEX FILE
  • LESSON 1: Generating Colored Light SOLUTION PROGRAM
  • LESSON 2: Creating Functions SOLUTION HEX FILE
  • LESSON 2: Creating Functions SOLUTION PROGRAM
at 9:09:00 PM Labels: BBC Micro:bit, Coding for Kids, Makecode, Programming Lessons, Programming Toys for Kids, Scratch
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

0 comments:

Post a Comment

Thanks for dropping by my blog! It really means a lot that you spare the time to read... and comment! Don't forget to check the "Notify Me" box so you will be notified of my response.

Newer Post Older Post Home
View mobile version
Subscribe to: Post Comments (Atom)

My Printable Shop

Search This Blog

DISCLOSURE

The Pinay Homeschooler is a participant in the Amazon Services LLC Associates Program, a program designed to provide means for websites to earn from the ads/promotion they create. We have included links to the products we used in our homeschool activities and if you buy via the links we may earn a small commission.

Follow Me on Social Media

BLOG MENU

SHOP PRINTABLES
FREE PRINTABLES
TODDLER LEARNING ACTIVITIES
PRESCHOOL
KINDERGARTEN
GRADE SCHOOL
THEMED UNITS
CHILDREN'S BOOKS
Prev Next
Follow Pinay's board Pinay Homeschooler on Pinterest.

Contact

If you have any concerns and found some errors in my posts and printables please let me know. I love receiving feedbacks! You can send me a message at pinayhomeschooler@gmail.com

Archive

  • ►  2025 (1)
    • ►  February (1)
  • ►  2024 (21)
    • ►  April (2)
    • ►  March (3)
    • ►  February (6)
    • ►  January (10)
  • ►  2023 (35)
    • ►  December (1)
    • ►  November (6)
    • ►  October (4)
    • ►  September (4)
    • ►  August (2)
    • ►  June (3)
    • ►  May (1)
    • ►  April (4)
    • ►  March (3)
    • ►  February (2)
    • ►  January (5)
  • ►  2022 (43)
    • ►  December (6)
    • ►  November (2)
    • ►  October (1)
    • ►  September (2)
    • ►  August (2)
    • ►  July (5)
    • ►  June (3)
    • ►  May (6)
    • ►  April (3)
    • ►  March (3)
    • ►  February (6)
    • ►  January (4)
  • ►  2021 (53)
    • ►  December (7)
    • ►  November (5)
    • ►  October (6)
    • ►  September (3)
    • ►  August (5)
    • ►  July (3)
    • ►  June (5)
    • ►  May (6)
    • ►  April (4)
    • ►  March (4)
    • ►  February (1)
    • ►  January (4)
  • ▼  2020 (40)
    • ►  December (4)
    • ►  November (2)
    • ►  October (1)
    • ►  September (5)
    • ►  July (2)
    • ►  June (2)
    • ►  May (2)
    • ►  April (3)
    • ►  March (6)
    • ►  February (7)
    • ▼  January (6)
      • Learning About Fruits Inside and Out
      • Oceania Australia Animals Math Packet
      • Valentine's Day Preschool Math and Literacy Mini Unit
      • Penguins Preschool Math and Literacy Mini Unit
      • FREE Winter Themed Printable Materials
      • Coding Lessons for Kids RGB Light Programming
  • ►  2019 (59)
    • ►  December (6)
    • ►  November (5)
    • ►  October (1)
    • ►  September (5)
    • ►  August (6)
    • ►  June (4)
    • ►  May (5)
    • ►  April (6)
    • ►  March (4)
    • ►  February (11)
    • ►  January (6)
  • ►  2018 (70)
    • ►  December (3)
    • ►  November (6)
    • ►  October (8)
    • ►  September (11)
    • ►  August (3)
    • ►  July (4)
    • ►  June (3)
    • ►  May (5)
    • ►  April (6)
    • ►  March (5)
    • ►  February (8)
    • ►  January (8)
  • ►  2017 (140)
    • ►  December (7)
    • ►  November (6)
    • ►  October (10)
    • ►  September (12)
    • ►  August (9)
    • ►  July (16)
    • ►  June (13)
    • ►  May (11)
    • ►  April (14)
    • ►  March (13)
    • ►  February (14)
    • ►  January (15)
  • ►  2016 (202)
    • ►  December (8)
    • ►  November (14)
    • ►  October (13)
    • ►  September (17)
    • ►  August (14)
    • ►  July (21)
    • ►  June (18)
    • ►  May (15)
    • ►  April (24)
    • ►  March (24)
    • ►  February (19)
    • ►  January (15)
  • ►  2015 (152)
    • ►  December (8)
    • ►  November (17)
    • ►  October (14)
    • ►  September (15)
    • ►  August (6)
    • ►  July (14)
    • ►  June (14)
    • ►  May (22)
    • ►  April (13)
    • ►  March (13)
    • ►  February (11)
    • ►  January (5)
  • ►  2014 (144)
    • ►  December (7)
    • ►  November (13)
    • ►  October (17)
    • ►  September (15)
    • ►  August (13)
    • ►  July (16)
    • ►  June (15)
    • ►  May (10)
    • ►  April (12)
    • ►  March (7)
    • ►  February (10)
    • ►  January (9)
  • ►  2013 (94)
    • ►  December (1)
    • ►  November (8)
    • ►  October (7)
    • ►  September (7)
    • ►  August (7)
    • ►  July (7)
    • ►  June (10)
    • ►  May (11)
    • ►  April (10)
    • ►  March (8)
    • ►  February (12)
    • ►  January (6)
  • ►  2012 (90)
    • ►  December (2)
    • ►  November (11)
    • ►  October (12)
    • ►  September (3)
    • ►  August (9)
    • ►  July (7)
    • ►  June (4)
    • ►  May (7)
    • ►  April (8)
    • ►  March (9)
    • ►  February (7)
    • ►  January (11)
  • ►  2011 (45)
    • ►  December (5)
    • ►  November (12)
    • ►  October (8)
    • ►  September (6)
    • ►  August (8)
    • ►  July (6)
Powered by Blogger.