What to expect
In this activity, you will build a simple meter or gauge to visually represent the light level in a room or coming from a specific light source and display it using a dial. A servo is a special type of DC motor that allows for more precise use of the motor's position.
Connections
You’ll use servo motors later in the final activity for this unit and in a few of the activities in the next unit.
Materials
Micro:bit w/ USB cable
Driver Extension Board w/ External 4AA battery pack (or use the USB power adapter cable)
Servo
Cardboard
Tape
Paper
Screw Driver
2 Alligator Wires
Optional: Multimeter
Instructions
In this activity we will build a simple gauge to visually represent the light level in a room or coming from a specific light source. We will convert the 255 possible values for the light level permitted by the micro:bit to the 180 degree scale of the servo motor. We will use ranges between 0-45, 45-90, 90-125, and 125-180 to outline four intensity zones of the light.
The main parts of this activity are:
Build the gauge
Connect the Servo to Micro:bit system
Create the gauge intervals using the calibration program
Create and Test a Light Level Meter
Build the Gauge
Figure 1. Traced Circle on Cardboard
Create a circle on your piece of cardboard. Mark a dot with a pencil where you want the center of your circle to be on a piece of cardboard. Make sure not to make it too small. You can use string or trace a circular object you can find around the classroom to help make this perfect circle.
Figure 2. Cut Out Circle
2. Cut out the circle you just traced.
Figure 3. Circle with Servo on Top
3. Unscrew the plastic arm from the body of the servo motor.
Figure 4. Circle with Traced Face of Servo
4. Place the white gear face down on the center circle dot and trace the outline of the blue body of the servo directly under the white gear face.
Figure 5. Circle with Face of Servo Cut Out
5. Cut out the inside of this outline so that the servo fits snuggly into the keyed slot you made in your cardboard circle.
Figure 6. Gauge Pointer
6. Take a piece of paper and create a pointer for your gauge similar to the one pictured below. Make sure it is not too big for the circle you cut out. The example pointer is 2 inches by ½ inch.
Figure 7. Marking Holes on Pointer
7. Unscrew the two remaining screws that are on the plastic servo arm.
8. Center the arrow you made parallel to the plastic servo arm using the line you drew.
9. Take a pencil and poke two holes in the paper that is over the plastic holes in the servo arm where you unscrewed the two screws
Figure 8. Circle with Servo Inserted
10. Insert the servo body into the keyed hole you made in the cardboard and tape it onto the servo body.
Figure 9. Arm Screwed into Servo
11. Screw the servo arm back onto the white gear attached to the body of the servo.
Figure 10. Pointer Attached to Servo
12. Place the screws through the holes in the paper you made, and screw them into the servo arm.
Connect the Servo to Motor Driver Expansion Board and Micro:bit
Figure 11. Servo Connected to Expansion Board
Connect the servo to the driver expansion board. Connect the servo to the S1 pins on the micro:bit Driver Expansion Board. THE THREE WIRES NEED TO BE CONNECTED IN A SPECIFIC WAY. The brown wire should be connected to the “GND” pin in the S1 row. The red wire should be connected to the “VIN” pin in the S1 row. The yellow wire should be connected to the “S” pin in the S1 row.
Figure 12. Expansion Board with Micro:bit
2. Insert the micro:bit into the driver extension board (Make sure that the micro:bit is facing away from the Driver Expansion Board. Inserting the micro:bit the wrong way may damage the micro:bit or the Driver Expansion Board).
Figure 13. Extension Board with Cables Attached
3. Connect your micro:bit into your computer with the USB-A to microUSB cable.
4. Power the driver extension board by connecting the USB-A to power cable to your computer.
Create the gauge intervals using the calibration program
Figure 14. Drawn on Gauge
Download the servo position code.
Press the ‘A’ button on the micro:bit to point the arrow at the 0 degree servo mark and draw a straight line from the servo to the end of the cardboard circle.
Press the ‘B’ button on the micro:bit to point the arrow at the 45 degree servo mark and draw a straight line from the servo to the end of the cardboard circle.
Press both the ‘A’ and ‘B’ button on the micro:bit to point the arrow at the 90 degree servo mark and draw a straight line from the servo to the end of the cardboard circle.
Press the micro:bit logo on the micro:bit to point the arrow at the 125 degree servo mark and draw a straight line from the servo to the end of the cardboard circle
Shake the micro:bit to point the arrow at the 180 degree servo mark and draw a straight line from the servo to the end of the cardboard circle.
Use markers or a pencil to shade the different areas you created on the micro:bit.
Figure 18. “Map” Block Inside Code
Inside the “forever” block there is a dark red “map” block. This is the important block that is able to convert any range perfectly into the 180 range of the servo connector. It will allow you to display any input range with your new dial.
Test the Light Meter
Download the light gauge code onto the micro:bit. The micro:bit should instantly start moving across the 180 degree range of the gauge to represent the current light level around you.
Take your micro:bit to different areas of your school to see the difference in light.
Ideas for Going Further
If you have extra time, experiment with other built-in sensors (temperature, sound, etc.) on the micro:bit and try to use the dial to display the readings collected.
More info about servos
Servos are an interesting device. Want to learn more about how they work and where you might use them? Check this out: https://www.sparkfun.com/servos
Think about it
In this activity we learned how to connect a servo to the micro:bit motor driver expansion board and control it with a micro:bit. We also created a light dial that uses a servo to determine the light level in the room. Then we used this to explore different areas inside and around our school.
How can this light dial or other light dials be used in practical applications?
What are other applications that a servo could be used for?
Feedback link