กลับไปหน้ารวมไฟล์
temperature-and-humidity-sensor-with-led-lights-169e04-en.md

Environmental Dashboards: LED Temp Bar Graph

The Temperature LED Dashboard replaces complex text displays with a bold, instant visual indicator. By mapping the digital reading of a DHT11 sensor to an analog-like array of 10 LEDs, you create an incredibly legible, color-coded room thermometer.

button_led_basic_interaction_1772681969235.png

Converting Arrays to Visuals (Map Function)

Wiring 10 LEDs to pins 2 through 11 is tedious, but programming the logic is brilliant.

  1. The Sensor Read: float tempC = dht.readTemperature();. (Current room is 26°C).
  2. The Output Array: You want to scale the room.
    • 20°C = 0 LEDs on.
    • 30°C = 10 LEDs on.
  3. The Mapping: int ledLevel = map(tempC, 20, 30, 0, 10); (This mathematically converts the 26°C reading into the raw number 6).
  4. The Illumination Loop: You write a for loop that cycles from 0 to 10. if(i < ledLevel), it turns that specific LED HIGH! Consequently, 6 LEDs light up simultaneously.

Thermal Color Coding

To make the display truly professional:

  • The first 3 LEDs (20-23°C) are BLUE.
  • The middle 4 LEDs (24-27°C) are GREEN or YELLOW.
  • The final 3 LEDs (28-30°C) are bright RED, warning you immediately from across the room that the A/C has broken!

Requirements

  • Arduino Uno/Nano.
  • DHT11 / DHT22 Sensor Module.
  • 10 x 5mm LEDs (Various Colors) and 10 x Resistors.
  • A large breadboard properly utilizing the shared ground rails.

ข้อมูล Frontmatter ดั้งเดิม

title: "Temperature and Humidity sensor with LED Lights"
description: "Visual climate tracking! Rather than using a screen to display the temperature, build a glowing bar-graph of LEDs that climbs higher as the room gets hotter."
category: "Basic Electronics"
difficulty: "Easy"