| Pino micro:bit | Função | Notas |
|---|---|---|
| P0 | Tensão proporcional à temperatura | ~10 mV/°C — ver fórmula |
| 3V | Alimentação | |
| GND | Massa |
Temp = (analogRead(P0) × 3300 / 1023 - 500) / 10 → Celsius. A constante 500 corresponde a 0°C = 500 mV. Pode variar ligeiramente entre módulos.Lê e converte para Celsius no Monitor Série.
function lerTemp(): number {
let raw = pins.analogReadPin(AnalogPin.P0)
return Math.round((raw * 3300 / 1023 - 500) / 10)
}
basic.forever(function() {
serial.writeValue("temp", lerTemp())
basic.pause(1000)
})Termómetro na matriz do micro:bit.
basic.forever(function() {
let t = (lerTemp()) // usa função acima
basic.showNumber(t)
if (t > 28) basic.showIcon(IconNames.Sad)
basic.pause(2000)
})