The rotary knob is another sensor; this sensor measures how much you have turned the knob. You can use the Duo Knob block to find the value of this sensor. This value will be between 0 and 100. Always remember to make sure that the Duo Knob block is set to the port attached to the rotary knob.
BirdBlox: Lessons for Hummingbird (Part 2)
Module 6: Rotary Knob
Attach the knob to the Hummingbird board. Write a script that continually displays the value of the Duo Knob block. Then turn the knob all the way to the left. What is the value of the Duo Knob block? What is the value of the Duo Knob block when the knob is turned all the way to the right?
Write a program that turns on a single color LED when the knob is turned far enough to the left. When the knob is turned far enough to the right, the LED should be off. What will your threshold be for this program? Remember, the threshold is the value that the Boolean block uses to make a decision.
In the previous exercise, you used the rotary knob to decide whether the LED should be on or off. Instead, you could use the knob to determine the brightness of the LED. Because the Duo Knob block is a number between 0 and 100, you can place it inside the Duo LED block to set the intensity of the light. Try out the script below. The forever loop repeatedly changes the brightness of the LED to match the value of the knob.
Use the knob to control a gear motor and the amount of red in a tri-color LED (the amount of green and blue can be whatever you want). These components should change at the same time.
Don’t forget to set the port in the sensor block to the port on the Hummingbird board that you are actually using! If the value of the sensor is not changing as expected, be sure to check that the sensor block is reading the correct port.
Module 7: Light Sensor and Putting It All Together
The light sensor measures the amount of light around it. This sensor is very similar to the other sensors that you have learned about. You can use the Duo Light block to find the value of this sensor. This value will be between 0 and 100. Always remember to make sure that the Duo Light block is set to the appropriate port.
Attach the light sensor to the Hummingbird board. Use the Duo Light block to measure the amount of light in your room. Then measure the value of the light sensor when you cover it with your hand. The average of these two values is a good threshold for the light sensor.
Write a script that turns on a vibration motor when the light sensor detects that it is dark. Otherwise, the vibration motor should be off.
You have now practiced using all the Hummingbird motors and lights, as well as three of the sensors. There are other sensors, including a temperature sensor and a sound sensor. These work very similarly to the sensors you have already used. The Duo Temperature C block tells you the temperature in Celsius, and the Duo Sound block tells you the amount of noise around the Hummingbird on a scale of 0-100.
The last two exercises below will give you some practice using multiple sensors. After you have completed these, you will be ready to create many exciting, unique Hummingbird robots!
Write a program that uses the knob sensor to control the color of a tri-color LED. However, the LED should only be on when an object is less than 30 cm from the distance sensor. Otherwise, the LED should be off.
Write a program that sends the servo to four different angles based on the values of the distance and light sensors. All of the values are shown in the table below.
|Greater than 20 cm||Above the threshold||0°|
|Greater than 20 cm||Below the threshold||60°|
|Less than 20 cm||Above the threshold||120°|
|Less than 20 cm||Below the threshold||180°|
Congratulations! You have completed Hummingbird BirdBlox training. Have fun making robots!