Lesson | Analog Meter | Micro:Bit

Overview

Analog meters are all around us!. They are used to visually represent measurements and data. One of the most common analog meters is the fuel needle in a car. This converts a reading of the fuel level in the tank to an empty to full reading on the meter.

In this build, we will use one servo to build an electronically controlled meter. We will first simply use the knob on the control board to move the needle converting the knob position to movement of the needle. Then, a sound sensor will be connected to convert sound level (ie music) to a meter reading. This will make it what is commonly known as a “VU-meter”

Skills + Goals

Carpentry

Use of basic tools and hardware

Construction

Following visual assembly instructions

Code

Understand math/code behind converting input readings to output readings (meter)

Age 10+

Time 60 min

Materials

  • A 1 x Screwdriver with the S1 and P0 bits
  • B 1 x Servo Sock
  • C 4 x #6 x 1/2" Wood Screws
  • D 2 x Binder Clips
  • E 1 x Meter Card
  • F 1 x Meter Needle
  • G 1 x Spacer
  • H 1 x Meter Back Board

Build Steps

Step 1

Start with the base plate, the holes for mounting the Servo Sock should be at the bottom

Step 2

Line up the disc of the Servo Sock [A] with the hole in the backplate and using 2 screws [B] to mount the Servo Sock

Note - It can be easier to line up and hold in place if you first “pilot” the screws into the backplate so they are slightly poking through the wood.

Step 3

Gather up the needle, wood spacers and 2 screws.

Step 4

Use the screwdriver and 2 screws [C] to attach the needle [B] and spacer [A] to the Servo Sock disc.

Step 5

Using the 2 binder clips [A], attach the meter card [B] to the backplate.

Note - the meter card can be drawn on to represent the minimum and maximum information you want to read. For example 0-100, quiet-loud, cold-hot, etc

Step 6

Connect the servo connector to the first connection (labeled 15) [A] on the control board.

Next connect the USB power connection to either your USB battery or a usb power supply (ie phone charger).

Next, hook up the sensor wire to the Pin 4 connection [B] (the colours should line up the same)

Hook up the sensor to the other end of the cable making sure that the "s" pin in connected to the orange/signal wire and the Brown to the "G"

Turn on the power switch to power the Micro:Bit and the Animate Breakout Board

*Note - If the sensor is not sensitive enough you can adjust the sound sensitivity with a Philips #0 bit

The Code

The example below illustrates how the code can retreive a sensor value and convert them it to meter movement (servo position)

You can code your Micro:Bit with the code below or, you can use our prebuild Animate Breakout Code

Code Breakdown

  1. Create variables called “sensor_value” and “servo_value”.  Variables are like containers to hold data. 
  2. Store the current value of the sensor connected to P4 by using an analog read block. Note – To test the servo change this to P0 and use the first knob on the Animate Breakout board to move the servo
  3. Using the map block, map the sensor values that range from 0-1023 to values for our servo 0-180.  Notice we mapped the opposite 180-0 to reverse the direction of the servo
  4. Write the servo_value to the servo connected to P15
  5. Use a Pause block to give the servo time to move to the servo value.  In this example, we use the “sensor_value” for the length of pause.  For example, a sensor value of 1000 means the servo will have 1000ms (1 second) to move.

Questions

Q | Where else are analog meters used?
A | Car Speedometer
A | Tire Pressure gauge
A | Hydro meter (older ones)
Q | If you have a range of 0-100 and a value of 20, what will the value be if mapped to a range of 0-10?
A | 2
Q | When using screws with wood to attach stuff, why is is helpful to “pilot” a screw
A | It helps to line up the parts and makes driving the screws much easier being already in the part

Assessment

  • Was the project assembled successfully
  • Was the concept of how input values are converted to output values understood