Case 02 Colorful Interaction
Introduction
In this course, we will guide students to explore the rainbow light function of XGO Rider, learn how to control the light through two programming methods: color blocks and three primary colors, and how to program the speaker to play music. Students will have a deep understanding of the principles of the three primary colors, the sound mechanism of the speaker, and how to control these functions through programming.
Teaching objectives
- Understand the principle of the three primary colors.
- Learn to control the color changes of the rainbow light through programming.
- Understand the sound principle of the speaker.
- Learn how to make the speaker play music through programming commands.
Teaching preparation
Before starting teaching, please make sure you have prepared the following necessary materials:
micro:bit V2 | |
---|---|
XGO-Rider | |
USB Cable | |
PC |
These materials will provide you with a complete experience, ensuring that you can smoothly carry out subsequent operations and learning. If you have prepared the above content, we can proceed to the next step.
After turning on the XGO Rider, in order to keep the fuselage balanced, it needs to move back and forth slightly. Please do not place the XGO Rider on the edge of the table or in a dangerous place to avoid damage.
Teaching process
Course introduction
In the last class, we wrote the first XGO Rider programming control program and understood the communication serial port setting principle between micro:bit and XGO Rider. In this class, we will learn in depth how to control the colorful lights and music rhythm of XGO Rider through programming to make the robot's performance more vivid and interesting.
Next, follow the tutorial of this lesson to learn the programming control knowledge of the robot's colorful lights and music rhythm.
Exploration activities
Exploration of three primary colors: Why are red, green, and blue called the three primary colors? Can other colors also be used as primary colors?
Sound principle: How is sound produced? What is the range of sound that humans can hear?
Programming control: How to control the rainbow lights and speakers of XGO Rider through programming?
Start programming
Add XGO Rider software library
1. Enter "makecode.microbit.org" and click New Project.
2. Enter the project name in the pop-up window and click Create.
3. Click Extension in the code drawer, enter XGO Rider in the search box on the pop-up interface and click the search icon. Click it after the XGO Rider software library is displayed.
Sample Program
Reference Program Link: https://makecode.microbit.org/_DaqEiW09mRef
Because XGO Rider has forward and backward movement in the performance mode, please place XGO Rider on a spacious flat ground.
Download Program
1. Use a USB cable to connect PC and micro:bit V2.
2. After the connection is successful, a drive letter named MICROBIT will be recognized on the computer.
3. Click in the lower left corner and select Connect Device.
4. Click。
5. Click。
6. Select BBC micro:bit CMSIS-DAP in the pop-up window, and then select Connect. At this point, our micro:bit has been successfully connected.
7. Click Download program.
Teamwork and Presentation
Students are divided into groups to complete the programming of XGO Rider rainbow lights and speakers.
Students are encouraged to cooperate, communicate and share experiences with each other.
Each group has the opportunity to show their programming results to other groups and make demonstrations.
Expected results:
Summary and reflection
Review the content of this course and confirm the knowledge and skills that students have mastered.
Guide students to discuss the problems and difficulties encountered in the production process, as well as solutions.
Think about how to further optimize the programming so that the rainbow lights change with music.
Expand knowledge
Principle of three primary colors
The three primary colors are the basic concepts in color theory, referring to three basic colors, which can produce a series of other colors by mixing in different proportions. In different color systems, the definitions of the three primary colors are different.
Three primary colors of light: In the additive color model of light, the three primary colors are usually defined as red (Red), green (Green) and blue (Blue), referred to as RGB. This model is based on the three photoreceptors on the retina of the human eye, which are most sensitive to red, green, and blue light. By adjusting the intensity of these three colors of light, a wide range of colors that the human eye can perceive can be synthesized. Therefore, the RGB model is widely used in televisions, computer monitors, and other display technologies.
Three primary colors of pigments: In the subtractive color model of pigments, the three primary colors are cyan, magenta, and yellow, referred to as CMY. These color pigments produce mixed colors by absorbing or reflecting light of different wavelengths. In the field of printing, the CMY color model is widely used because it can reproduce rich colors by mixing different proportions of cyan, magenta, and yellow inks.
The three primary colors were chosen as red, green, and blue (or cyan, magenta, and yellow) because these colors are more evenly distributed in the visual spectrum and the human eye is more sensitive to them. From a mathematical point of view, any color can be regarded as a linear combination of these three colors, which makes them an ideal basis for building color spaces.
However, it should be noted that although any color can be synthesized by mixing the three primary colors in theory, not all colors can be perfectly reproduced due to physical limitations (such as the purity of the pigment, the brightness and contrast of the display device, etc.). In addition, some special colors, such as gold and silver, are usually not included in the traditional three-primary color model because they are achieved by reflection of light rather than absorption.
Principle of sound generation
Sound is generated by vibration. When an object vibrates, it causes compression and rarefaction fluctuations in the molecules in the surrounding medium (such as air, water or solid), which propagate in the form of waves to form sound waves. The propagation of sound waves requires a medium, but it cannot propagate in a vacuum.
Principle of sound generation:
- Vibration: The vibration of an object is the basis for the generation of sound. When an object vibrates, it causes displacement of the surrounding medium molecules.
- Medium: Sound requires a medium to propagate. Sound waves propagate at different speeds in solids, liquids and gases, usually fastest in solids and slowest in gases.
- Waveform: Sound waves are mechanical waves that transfer energy through molecules in a medium. The waveform of a sound wave can be a simple sine wave or a more complex waveform, depending on the vibration characteristics of the sound source.
The range of sounds that humans can hear: The human auditory system has certain limitations on the frequency range of sounds. Most people can hear sounds in the frequency range of about 20 Hertz (Hz) to 20,000 Hertz (20kHz). This range is called the hearing range.
Low-frequency sounds: 20Hz is the lowest frequency that the human ear can perceive, and sounds below this frequency are called infrasound.
High-frequency sounds: 20kHz is the highest frequency that most people can hear, and sounds above this frequency are called ultrasound.
It should be noted that as people age, their sensitivity to high-frequency sounds gradually decreases, which may make it impossible for the elderly to hear high-frequency sounds of 20kHz. In addition, individual differences can also affect the frequency range of sounds that a person can hear.
The loudness (or intensity) of a sound is usually measured in decibels (dB). 0 dB is the weakest sound that the human ear can perceive, while sounds above 120 dB may cause pain or damage to the human ear. The sound of everyday conversation is around 60 decibels.