In this chapter, we learn to
display text on the OLED display.
use gesture sensor as input.
Introduction: OLED and Gesture Sensor.
AI Task #1: Sweep the text "Hello EDU PICO" across the screen from left to right.
AI Task #2: Use hand gestures to control the text movement on the OLED display.
Activities: Build a hearing gesture reaction game with the gesture sensor and buzzer.
Challenge: Program a tone testing feature for better gaming experience.
You can think of the OLED display as a very small, electronic billboard. It's like the display on your smartphone but much smaller. Like an electronic billboard, you can choose what to show on it. In this activity, we will learn how to code and print on the EDU PICO V2's OLED display module.
-> Libraries: board, busio, time, adafruit_ssd1305, font5x8.bin.
-> OLED I2C Pins Configuration: SCL = GP5 and SDA = GP4.
Upon completion of the activity, you should be able to:
-> Invert OLED display at initialization with a bluish-white background.
-> The program will displayed text on OLED
"Hello" with a coordinate of x = 50, y = 20.
"World" with a coordinate of x = 13, y = 35.
Task:
-> Sweep the text "Hello EDU PICO" across the OLED display from left to right.
Upon completion of the activity, you should be able to:
-> See the text “EDU PICO!” moves smoothly across the OLED display. The text should continuously sweep from left to right.
Modify the code to allow user to type their name in the shell console and print the name on the OLED display. Replace the code from Line 7 to Line 11 with the code provided below.
-> Libraries: board, busio, time, adafruit_ssd1305, font5x8.bin.
-> OLED I2C Pins Configuration: SCL = GP5 and SDA = GP4.
Upon completion of the activity, you should be able to:
-> Build a program to display your name on OLED
In this section, we'll explore how PAJ7620 gesture sensor can be used to detect hand gestures. The PAJ7620 is a tiny electronic device that can "see" hand gestures and measure the amount of light around it. It's like having a tiny robot eye!
-> Libraries: board, busio, edupic2_paj7620.
-> PAJ7620 I2C Pins Configuration: SCL = GP5 and SDA = GP4.
-> Input: By performing various hand gestures in front of the sensor, the code will print the corresponding direction to the shell console:
"left" when moving from right to left.
"right" when moving from left to right.
"up" when moving from down to up.
"down" when moving from up to down.
Upon completion of the activity, you should be able to:
-> The program code will display direction in the shell console after performing various hand gestures.
Task:
-> Use hand gestures to control the text movement on the OLED display.
Upon completion of the activity, you should be able to:
-> See the text “EDU PICO!” moves on the OLED display in the same direction as your hand movement.
Let' s build our first arcade game. But this won 't be your typical game, instead, this is going to help players improve their hand-ear coordination. In this project, we 'll learn to integrate OLED display, buzzer, and PAJ7620 gesture sensor, so be prepared for a slight increase in difficulty. Ready? Let' s get started!
Since we are building a reaction arcade game with OLED display, why not we challenge ourselves to make it even better? Let’s provide the player more information about the test tones when they press Button A.
-> Libraries: board, digitalio, time, simpleio, busio, edupico2_paj7620 adafruit_ssd1306, random, font5x8.bin.
-> OLED & PAJ7620 I2C Pins Configuration: SCL = GP5, SDA = GP4.
-> Audio / Buzzer Configuration: Buzzer to GP21.
-> Button Configuration:
button_tone (Yellow) to GP0 as digital input.
button_start (Blue) to GP1 as digital input.
-> Input:
Pressing Button A will activate test tone, playing Do Re Mi Fa in sequence.
Pressing Button B will start the game with a "Ready" and "Swipe!" countdown.
The player has to react to the random tone with either UP, DOWN, LEFT or RIGHT hand gestures.
-> Libraries: board, digitalio, time, simpleio, busio, edupico2_paj7620 adafruit_ssd1306, random, font5x8.bin.
-> OLED & PAJ7620 I2C Pins Configuration: SCL = GP5, SDA = GP4.
-> Audio / Buzzer Configuration: Buzzer to GP21.
-> Button Configuration:
button_tone (Yellow) to GP0 as digital input.
button_start (Blue) to GP1 as digital input.
Upon completion of the activity, you should be able to:
-> The buzzer will play a random game tone, either DO, RE, MI, or FA.
-> If the player gives a wrong answer, the OLED will display "Try again" with a sad beep.
Upon completion of the activity, you should be able to:
-> Press button A to get information about test tones