Introduction
What is the difference between a digital input and an analog input?
In this guide, you will be introduced to analog inputs using an external potentiometer. Learn to program it using MakeCode to measure its voltage.Â
Once you have finished this guide, you will understand what analog inputs are as well as how to use potentiometers with the micro:bit.
-
-
-
-
-
-
-
-
basic.forever(function () { basic.showNumber(pins.analogReadPin(AnalogPin.P0)) basic.pause(1000) })
-
let voltage = 0 let sensorVal = 0 let vcc = 0 vcc = 3.3 basic.forever(function () { sensorVal = pins.analogReadPin(AnalogPin.P0) voltage = sensorVal * (vcc / 1023) basic.showNumber(voltage) basic.pause(1000) })
-