Hi, today I’d like to introduce how to make a simple thermometer with micro:bit. I used the microbit to get the temperature and control the steering gear. First, let us start with the design part, and then we will enter the programming part.
What you need to do is to cut out the cardboard, draw a semicircle on it with a compass, and then make a label with the range of numbers you want, below is a picture description. Also, make a pointer to be driven by the servo.
Now let’s see how to use microbit to drive the servo. The servo requires a 3V voltage to run, we need to provide 3V from micro:bit to the servo. We need to get the output from PIN0 and get another connected to the ground. See the connection details:
Connect the ports on micro:bit in accordance with the descriptions above.
Diagram:
Picture:
Program part on MakeCode:
Write the above code, if the temperature is less than 20, then we will set the temperature variable to 20. If it is not, and the temperature exceeds 35 degrees, then we set the temperature to 35. You can choose any number you want based on the temperature of your location.
Now, we need to map these values to our servo to drive them. The program is shown in the picture above, and then we can see the temperature and the servo adjust according to the temperature. It looks like a simple thermometer.
Link: https://makecode.microbit.org/_7tiKbzDJDXh7
If you have any ideas or opinions, please feel free to contact us via services@elecfreaks.com.