Try comparing the temperature your board shows to a real thermometer in the same place. You might be able to figure out how much to subtract from the number the board shows to get the real temperature. Then you can change your program so the board is a better thermometer.
Temperature
Find the temperature where you are. The temperature is measured in Celsius (metric). The board can find the temperature nearby by checking how hot its computer chips are.
input.temperature();
Returns
- a number that is the temperature in degrees Celsius.
How does it work?
The board checks how hot its CPU (main computer chip) is. Because the board does not usually get very hot, the temperature of the CPU is usually close to the temperature of wherever you are. The board might warm up a little if you make it work hard, though!
Learn more about how the board can detect hot or cold in this video:
Example: board thermometer
The following example uses temperature
and show number
to show the temperature of the room.
basic.forever(() => {
let temp = input.temperature()
basic.showNumber(temp)
})
Example: Fahrenheit thermometer
This program measures the temperature using Fahrenheit degrees.
Fahrenheit is a way of measuring temperature that is commonly used in the United States.
To make a Celsius temperature into a Fahrenheit one, multiply the Celsius temperature by
1.8
and add 32
.
basic.forever(() => {
let c = input.temperature()
let f = (1.8 * c) + 32
basic.showNumber(f)
})