Back to: Multiplier Event Luxembourg
A temperature meter based on scaled values can be created by defining the minimal and maximal temperatures in degrees Celsius, depending on the user’s ambient temperature. Consequently, the temperature meter is more or less sensitive to temperature changes.
# Set values based on the user’s ambient temperature measured in degrees Celsius. temperature_min = 20 temperature_max = 40
Normalised temperature changes are calculated to scale the temperature values from the minimum to maximum temperature range. These normalised temperature changes are multiplied by ten to get values between 0 and 9. This allows us to map scale values to NeoPixel positions.

scale = round(10 * (cp.temperature - temperature_min) / (temperature_max - temperature_min))
The NeoPixels of the Circuit Playground Express board, whose position number is less than the scaled value of the temperature, are turned on and otherwise turned off. The temperature is continuously measured every second, which refreshes the state of the NeoPixels.
Once again, the student should breathe on the temperature sensor or hold a heat or cooling source near it to observe whether the number of NeoPixels turned on changes.
It should also be possible to observe minimal temperature variations while the Circuit Playground Express is placed on a desk and when the user holds his/her finger over it. For optimal results, the user should consider adjusting the temperature meter’s minimal and maximal temperatures to match his/her ambient temperature values.