Temperature Sensor Challenges
The temperature sensor integrated into micro:bit detect the ambient temperature in Celsius degrees.
Challenge #1: Digital Thermometer
A thermometer is an instrument used to measure temperature. The most common type consists of a sealed glass capillary tube ending in a small reservoir containing a certain amount of mercury or alcohol. This mercury or alcohol expands when the temperature rises and contracts when it falls, and the resulting volume changes are read on a graduated scale.
Digital thermometers use transducer devices and electronic circuits to convert the small voltage variations into numerical values, ultimately displaying the temperature on a screen.
Objective.
Display on the LED panel the temperature detected by the temperature sensor integrated into the micro:BIT.
Code description.
We suggest using the ‘On Start’forever’ event, which is in the ‘Basic’Basic’ category. This block allows the code entered to be executed whenduring all the micro:BIT starts up.program.
Add the "show number" block, located in the Basic category. This block displays the entered number on the LED screen, scrolling it if it has more than one digit.
Replace the number “0” with the value obtained from the temperature sensor. This block is located in the Input category.
Next, the screen is cleared and a 1000 ms pause is introduced. The program then looks like this:
A vertical bar will appear in the simulator allowing the temperature to be adjusted; the selected temperature is the one displayed on the LED panel.

Extra exercise.
Create a program that displays the temperature in degrees Celsius when button A is pressed, and displays the temperature in degrees Fahrenheit when button B is pressed.
RetoChallenge Aviso#2: deWarning: placaspatches deof hielo.
ice.
LaMost mayoríacars de coches incorporan en el salpicadero, juntofeature a lasnowflake-shaped pantallawarning quelight marcaon lathe temperaturadashboard, exterior,next unto testigothe conoutside formatemperature dedisplay, copoto dealert nieve,the quedriver avisato dethe lapotential posibilidadpresence deof queice hayapatches placason dethe hieloroad. enThis lalight carretera.typically Esteilluminates testigowhen sethe sueletemperature iluminardrops cuando la temperatura baja debelow 3 gradosdegrees centígrados.Celsius.
Objetivo.
Objective.
MostrarDisplay ena elsnowflake icon on the micro:bit's LED panel LEDwhen dethe latemperature micor:BITis un icono con forma de copo de nieve cuando la temperatura esté por debajo debelow 3 grados.degrees.
Code description.
To start the program, it is proposed to use the "forever" event. Next, the "if... then" logical operator, found in the Logic section, must be added. This block checks whether a condition is met; if so, it executes the entered instructions.
To check if the temperature is below 3 degrees Celsius, the operator that returns "true" whenever 3 is greater than the value reported by the temperature sensor will be used. The block is located in the Logic category.
To display a snowflake-shaped icon, the "show LED" block will be used; the "clear screen" block must also be added so that the LED panel does not remain lit when the temperature rises above 3°C, but with a delay to make sure that the signal is visible.
Once the code is finished, the ice symbol will appear when the temperature drops below 3°C.

DescripciónExtra del código.exercise.
ParaAdd iniciaran elaudible programa,alert sewhen proponethe usartemperature eldrops evento para siempre. Posteriormente se debe añadir el operador lógico si … entonces situado en la sección Lógica. Este bloque verifica si es verdad que se cumple una condición, si es así, ejecuta las instrucciones introducidas.

Para comprobar si la temperatura está por debajo de los 3º centígrados se usará el operador que devuelve verdadero siempre quebelow 3 seadegrees mayor que el valor reportado por el sensor de temperatura. El bloque se localiza en la categoría Lógica.

Para mostrar un icono con forma de copo de nieve se usará el bloque mostrar LED, también se debe añadir el bloque borrar la pantalla para que no se quede encendido el panel LED cuando suba la temperatura de 3º centígrados

Una vez terminado el código, aparecerá el símbolo de hielo, cuando la temperatura sea menor de 3º centígrados.

Propuesta.
Añadir un aviso sonoro cuando la temperatura sea inferior a 3 grados celsius.Celsius.
Reto Temperatura óptima de una nevera
La temperatura óptima de un frigorífico es de 7ºC, mientras que la temperatura de un congelador debe estar entorno a los -18ºC. Algunas neveras incorporan un avisador acústico que se activa cuando la temperatura no es la óptima.
Objetivo.
Mostrar en el panel LED de la micro:BIT la temperatura del frigorífico y activar una alarma cuando la temperatura esté por encima de 7ºC
Descripción del código.
En este reto se incorpora un altavoz como actuador externo. Se conectará uno de los polos al GND y el otro al PIN 0.
Para iniciar el programa se usará el bloque “para siempre”. Dentro se situará el condición “si entonces”. La condición a verificar será: si la temperatura es mayor de 7 grados.

Si el valor es verdadero entonces se reproducirá un tono de aviso.
También se muestra la temperatura medida.

En el simulador se puede variar la temperatura para comprobar el correcto funcionamiento del programa.
Information extracted and translated from catedu.







