Watch/Listen Here:
OR Read below:
STEP 3: Sensors
Since you know how to control the brightness of the LED and pitch of the SPEAKER using a specific number that you set with the dial, what if instead, we use other factors as the controller?
Pick up the DISTANCE block. Notice how it only has one male connector, meaning that it can only send values to connected blocks.
Protruding on the other side is a pair of circular "eyes". Using ultrasonic sound waves similar to a bat, the sensor can figure out the distance between its "eyes" and an object in front of it.
Now replace the NUMBER block from your previous setup with the DISTANCE block.
Clear about a 2 feet of space in front of the DISTANCE block to test it out.
Using your hand or a flat object like a sheet of paper, slowly move back and forth while keeping aligned with the sensor and watch or listen to the SPEAKER and LED blocks react!
When the object is closer to the sensor, is the pitch of the SPEAKER higher or lower? Is the LED brighter or dimmer?
You will notice that as the object gets closer, the DISTANCE sensor sends a smaller value, which results in the pitch of SPEAKER and brightness of LED lowering.
Short Distance
Low Pitch
Low Brightness
High Pitch
High Brightness
Long Distance
There are many kinds of sensors for you to try! You can go to Meet the Blocks to check them out. Most of the "INPUTS" are sensors! Here's one combination I recommend:
The COLOR block can read the color of an object over it. The RGB block, which is basically an LED that can display the full rainbow of colors, can receive the signal from the COLOR block and show you the actual color being sensed!
Challenge Yourself!
Can you use the COLOR block next to the SPEAKER block to hear what different colors sound like?
​
Which is the higher pitch? Red or Green? Can you figure out the order of colors from low to high pitch?
​
Hint: You can also add the RGB block to see and check the color that is being read by the sensor.
Red is lower than green because the order from low to high is Red, Orange, Yellow, Green, Blue, Purple, Pink!