thermometre-couleur.ino

Arduino Esplora — Board Fiche · File : thermometre-couleur.ino · Language : Arduino · Use case : Afficher la température embarquée en dégradé bleu-rouge

The onboard temperature sensor tracks ambient air within a few degrees — blow on it to watch it react. The LED slides from blue to red with temperature, and the monitor prints degrees.

Hardware required

An Arduino Esplora (ATmega32U4, 5 V) with its onboard sensors: joystick, 4 buttons, slider, RGB LED, buzzer, light, temperature, sound and accelerometer. None.

Wiring

Nothing to wire; keep fingers away from the board while measuring.

How it works

readTemperature(DEGRE_C) converts the analog sensor to Celsius; the color interpolates blue (cold) to red (hot). In the Arduino IDE, select « Arduino Esplora »; add the « Esplora » library from the Library Manager to reach the onboard sensors.

Going further

Add an audible alert (Esplora.tone) past a threshold, or plot the curve in the serial plotter.

thermometre-couleur.ino

// Capteur de temperature embarque -> couleur + moniteur serie.
#include <Esplora.h>

void setup() {
  Serial.begin(9600);
}

void loop() {
  float c = Esplora.readTemperature(DEGRE_C);
  Serial.println(c, 1);
  int chaud = constrain((int)((c - 15) * 20), 0, 255); // 15..28 degres
  Esplora.writeRGB(chaud, 0, 255 - chaud);             // bleu -> rouge
  delay(250);
}

← Back to the board