Lesson 03 Trimpot

Introduction

Trimpot or potentiometer is a kind of common pressure adjustment components. In the following experiment, we are going to read the output voltage on the trimpot and display it using the nicro:bit 5*5 LED matrix display with a bar graph representation.

Component List

  • micro:bit board
  • Micro USB Cable
  • Pi Supplymicro:bit breadboard adaptor
  • Breadboard
  • 10K Trimpot
  • Male to Male Jumper wires

Trimpot

Trimpot is a kind of adjustable electronic component thats changes its resistance. It consists a resistor and a rotary or sliding knob, they come in different forms. When adding a voltage to one of the fixed contact pins, by changing the place of contact with rotary or sliding system, the voltage output will change because of the variable resistance. Most of the time, it works as a voltage divider.

Hardware Connection

Connect your components according to the breadboard diagram below:

After connecting the circuit, you should see the following:

Rotate trimpot, then the output voltage will change from 0V to 3.3V as with the rotation of the trimpot.

Programming

Click to open Microsoft Makecode Online Editor, write your code in the edit area. By now you should be comfortable in writing your own code in the online editor.

Of course, you can see the whole program in the link below. Just click the Edit on the right top corner , and then click Download on the right bottom corner to download code into Micro:bit.

Link of the whole program: https://makecode.microbit.org/_Kax5tiaRWXxU

Code Explanation

plot bar graph displays a bar graph of the numbers you give it. A bar graph is a kind of chart that shows numbers as lines with different lengths.

analog read Read an analog signal (0 through 1023) from the analog pin.

Results

Rotate the trimpot, voltage value will be displayed on micro:bit 5*5 LED screen with a bar graph. When voltage read out to be “0”, LED screen displays a pixel spot only. While the voltage rises to 3.3V, LED screen will be fully illuminated.

Taking it further

If we want to use the trimpot to adjust the brightness of an LED, then how would you design the circuit and program? Think about some of the previous lessons we have done and if need be go back and do them again.

micro:bit Starter Kit Lessons

  • Lesson 01 – LED
  • Lesson 02 – Button
  • Lesson 03 – Trimpot
  • Lesson 04 – Photocell
  • Lesson 05 – RGB LED
  • Lesson 06 – Self-lock Switch
  • Lesson 07 – Temperature Sensor
  • Lesson 08 – Servo
  • Lesson 09 – Buzzer
  • Lesson 10 – Motor
  • Lesson 11 – Rainbow LED
  • Lesson 12 – Accelerometer
  • Lesson 13 – Compass
  • Lesson 14 – Ambient Light
First published at 10:20am on July 9, 2019
Last updated at 10:20am on July 9, 2019