In this chapter, we learn to
program EDU PICO V2 to light up RGB LEDs in different colours.
read colour data with colour sensor.
Introduction: RGB LEDs and Colour Sensor.
AI Task #1: Make the RGB LEDs show a running rainbow colour effect.
AI Task #2: Use the colour sensor to detect red, green, or blue and show that colour on the RGB LED module.
Activities: Build a colour detection game.
Challenge: Improve the game by programming a colour hint indicator using a single RGB LEDs.
In this introduction, you will learn how to control the RGB LEDs module to create dazzling displays of colour and patterns! Once you're done with the sample code, make sure to try building something with your own way.
-> Libraries: board, time, neopixel.
-> RGB LEDs Configuration: num_pixels = 5, pixel_pin = GP14.
Upon completion of the activity, you should be able to:
-> The program will turn all LEDs on (blue color) and off with a 1 second interval.
-> Click here to download code
Task:
-> Make the RGB LEDs show a running rainbow colour effect.
Upon completion of the activity, you should be able to:
-> See the RGB LEDs lights up multiple colours at once, to form a rainbow pattern continuously.
In this chapter, we will explore a sensor that can measure light. Light can be described in different ways, from how bright it is to the colours we see when it reflects off objects. By learning how to detect brightness and colour, we can begin to understand how machines perceive the world around them too.
-> Libraries: board, time, busio, neopixel, adafruit_opt4048.
-> RGB LEDs Configuration: num_pixels = 5, pixel_pin = GP14.
-> OPT4048 I2C Pins Configuration: SCL = GP5, SDA = GP4.
-> Input:
Hold the colour cards above the colour sensor.
Upon completion of the activity, you should be able to:
-> The program will light up the RGB LEDs in white colour at 20% brightness.
-> The color sensor reads and display the amount of red (r), green (g), blue (b), and clear (c) light values with a 1 second interval.
-> Click here to download code
Task:
-> Use the colour sensor to detect red, green, or blue and show that colour on the RGB LED module.
Upon completion of the activity, you should be able to:
-> See the RGB LEDs colour changed according to the coloured objects that is placed in front of the colour sensor.
Did you know that approximately 300 million people worldwide have colour vision deficiency, also known as colour blindness? This condition can make it difficult to distinguish between colours, affecting a person's education, academic performance, and even career choices. In this project, we will learn how to build a basic colour detection game by integrating colour sensor, RGB LEDs, buzzer, button and OLED display.
In this challenge, you are required to add a hint function for the player while maintaining the flow of the game. Program only the first RGB LED (ID:0) to light up in the random colour similar to the colour text shown on the OLED. This helps players match colours more easily and sharpen their colour recognition skills. Give it a try!
-> Libraries: board, digitalio, time, simpleio, neopixel, busio, random, adafruit_ssd1306, adafruit_opt4048.
-> OLED & OPT4048 I2C Pins Configuration: SCL = GP5 and SDA = GP4.
-> Audio / Buzzer Configuration: Buzzer to GP21.
-> RGB LEDs Configuration: num_pixel = 5, pixel_pin = GP14.
-> Buttons Configuration: button_start (Yellow) to GP0 as digital input.
-> Input:
Press Button A to start the game with a 5 second countdown.
The player must quickly place the correct colour card above the colour sensor once the RGB LEDs white light turns on.
-> Libraries: board, digitalio, time, simpleio, neopixel, busio, random, adafruit_ssd1306, adafruit_opt4048.
-> OLED & APDS9960 I2C Pins Configuration: SCL = GP5 and SDA = GP4.
-> Audio / Buzzer Configuration: Buzzer to GP21.
-> RGB LEDs Configuration: num_pixel = 5, pixel_pin = GP14.
-> Buttons Configuration: button_start (Yellow) to GP0 as digital input.
Upon completion of the activity, you should be able to:
-> Display text of a random color on the OLED
-> The buzzer will play an exciting tone with a "Well Done!" message printed on the OLED, if the player gets the correct colour.
-> The buzzer would beep 3 times and the OLED would proceed to display text "Try Again", if the player got the wrong color.
-> The RGB LEDs will turn off after the countdown of 5 second ends.
Upon completion of the activity, you should be able to:
-> Build a function in the program to generate the random colour to eliminate the possibility of repeating the same colours.