Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

This Arduino project uses an ultrasonic sensor to make a hot/cold-style proximity indicator: the red LED brightens as an object gets closer, while the blue LED represents greater distances. “Hot” and “cold” are metaphors here—the circuit detects distance, not temperature.

What the detector does

Make’s tutorial by Julius Schmiedel describes an Arduino Uno, a Parallax Ping ultrasonic sensor, and two LEDs. The sensor measures the distance to an object; the Arduino translates that reading into red and blue LED brightness. The tutorial is dated December 18, 2012, with a later date of May 28, 2015, and gives an estimated build time of 30 to 60 minutes. Those are the source’s stated dates and estimate, not independently verified build results. Read the Make project.

Parts and wiring

Parts named in the tutorial

  • Arduino Uno board and USB cable
  • Parallax Ping ultrasonic sensor
  • Breadboard and jumper wires
  • Super-bright red and blue LEDs
  • 56Ω and 150Ω quarter-watt resistors, plus a carbon-film resistor assortment

Connect the sensor and LEDs

The Ping sensor has three labeled pins: GND, 5V, and Sig. Connect GND and 5V to the corresponding Arduino power connections, and connect Sig to Arduino digital pin 7. The tutorial connects the red LED to pin 5 and the blue LED to pin 6. Each LED needs a current-limiting resistor in series, with the circuit returning to ground.

LED polarity matters: place the longer anode leg toward its Arduino pin and the shorter cathode leg toward the resistor and ground. The tutorial lists resistor values, but the appropriate value depends on the electrical characteristics of the particular LED. Check the LED’s specifications and calculate a suitable current-limiting resistor using Ohm’s law rather than assuming every LED uses the same value.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
ELEGOO 5PCS HC-SR04 Ultrasonic Module Distance Sensor Kit
  • NON-CONTACT DISTANCE SENSING: Add object detection to robot navigation, parking-distance prototypes, automatic lids, counters and interactive projects; each HC-SR04 uses a 40 kHz ultrasonic burst and echo timing to estimate distance
  • 5-PACK FOR REPEATABLE PROTOTYPING: Use multiple HC-SR04 modules across builds, compare sensor positions or keep spares for testing and replacement; each module integrates an ultrasonic transmitter, receiver and control circuit
  • 5 V MODULE WITH 3-450 CM RANGE: Connect VCC, Trig, Echo and GND, use a 10 µs trigger pulse and measure Echo duration; resolution is 0.3 cm with an effective angle under 15°, while the controller board and external power source are not included
  • PROTECT 3.3 V GPIO: The HC-SR04 operates from 5 V and its Echo output is 5 V, so use a voltage divider or suitable level shifting with 3.3 V inputs; keep the module dry and use it for prototyping rather than calibrated measurement
  • FOR ROBOTICS & STEM PROJECTS: Suitable for distance measurement, object detection, automatic lids, parking alerts, robot navigation and other hands-on electronics builds

How the V1 sketch turns distance into light

The V1 sketch sends a short pulse from the sensor, changes the signal pin to input, and times the returning pulse. It estimates distance by halving the round-trip time and dividing by 29, using the tutorial’s approximation that sound travels about one centimeter in 29 microseconds. The page says the Parallax sensor can measure up to 300 cm, but the sketch limits the usable range in software.

LED behavior described by Make

  • Red: begins to illuminate at 25 cm and grows brighter as an object approaches zero distance.
  • Blue: indicates the farther range, described in bands from 25 to 50 cm, and fades through the near region from 25 to 10 cm.

The sketch includes a 20-millisecond delay, which the tutorial characterizes as approximately 50 cycles per second before instruction overhead. These are descriptions of the example’s code and mapping, not guarantees of real-world measurement accuracy or update speed. Sensor readings can vary with the object and setup.

Rank #2
LAFVIN Simulation Ultrasonic Radar Sensor Module DIY Kit 180-Degree Scanning Detector Compatible with Arduino IDE
  • By utilizing the 180-degree scanning range of the servo motor, combined with the distance measurement capability of the ultrasonic sensor, for Arduino can detect targets and represent them on the screen with different colored dots.
  • The TFT screen provides intuitive visual feedback, allowing users to understand the distance information of the targets.
  • Distance Measurement: By using the ultrasonic sensor to measure the distance between objects and the sensor, it enables distance measurement and obstacle detection.
  • Direction Sensing: By controlling the direction of the sensor through the servo motor, it allows obtaining the approximate directional position of objects in space.
  • Real-time Monitoring: By continuously rotating the sensor and acquiring distance data, it enables real-time monitoring of the position and distance changes of objects.

Other behaviors in the same project

The tutorial also describes two alternate sketches using the same hardware arrangement: V2 turns the setup into a “capture the ping” game, and V3 makes proximity trigger an on/off switch. They change the software behavior; they do not turn the ultrasonic sensor into a temperature detector. The Make tutorial covers the V1, V2, and V3 versions.

If you mean actual temperature

A temperature detector needs a temperature-sensitive component. An ultrasonic sensor measures distance, so replacing it with a generic temperature-sensor module would be a different circuit and would require suitable wiring and code.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
WWZMDiB 2 Pcs HC-SR04 Ultrasonic Sensor Module Compatible with for Arduino R3 MEGA Mega2560 Duemilanove Nano Robot XBee ZigBee (2 Pcs HC-SR04 Ultrasonic Sensor)
  • HC-SR04 Ultrasonic Sensor:This is a device that can use sound waves to measure the distance of an object. It measures distance by emitting a sound wave of a specific frequency and listening to the bounce of that sound wave. The distance between the sonar sensor and the object can be calculated by recording the time elapsed between the generation of the sound wave and the bounce of the sound wave
  • Working Voltage: 5V DC;Quiescent current: less than 2mA
  • Ranging Distance:2cm - 450 cm;High precision: 0.3 cm
  • Effectual Angle: <15°
  • Test mode :Test distance = ((Duration of high level)*(Sonic :340m/s))/2

NTC thermistor approaches

SunFounder’s separate analog temperature sensor lesson describes an NTC thermistor, whose resistance decreases as temperature rises, paired with an LM393 comparator for analog and digital outputs. Its adjustable threshold can drive an indicator. See SunFounder’s analog temperature sensor lesson.

RED’s Energy Leak Detector is another distinct design: an NTC thermistor changes the balance of a bridge as temperature changes, while an amplifier and LM393 window comparator drive red or green LEDs for temperature rising or falling relative to ambient. The circuit is balanced before measurement, and a sensitivity control adjusts how much variation triggers the indicators. See RED’s Energy Leak Detector circuit.

Rank #4
2-Pack HC-SR04 Ultrasonic Sensor Kit with Mounting Brackets & Jumper Wires, 2cm-4m Range, for Arduino/Raspberry Pi Obstacle Avoidance & DIY Projects
  • COMPLETE HC-SR04 KIT – Includes 2 ultrasonic sensor modules, mounting brackets, screws, and jumper wires for robotics and electronics projects.
  • 2CM–4M DISTANCE DETECTION – Operates at 4.5–5.5V DC and measures objects across a wide range for obstacle avoidance and distance sensing.
  • SIMPLE 4-PIN INTERFACE – Clearly defined VCC, Trig, Echo, and GND connections make wiring and programming straightforward.
  • FOR ROBOTICS & DIY PROJECTS – Suitable for smart cars, obstacle-avoidance robots, student experiments, alarms, and home-automation prototypes.
  • ARDUINO & RASPBERRY PI PROJECT USE – Designed for common microcontroller and single-board-computer projects; verify the required logic voltage for your board.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choosing compatible replacement parts

The named Parallax Ping sensor may not be readily available. If you substitute a board or sensor, check compatibility rather than assuming the original sketch and wiring will work unchanged:

Best Value
Arduino Sensor Kit - Base [TPX00031] - Essential Sensors for Beginners, Includes 10+ Sensors for DIY Projects & Learning
  • Comprehensive Sensor Collection: The Arduino Sensor Kit - Base [TPX00031] includes over 10 essential sensors, such as temperature, light, motion, and humidity sensors, providing a complete foundation for learning and experimentation in electronics and IoT applications.
  • Ideal for Beginners and Education: This kit is designed for beginners, making it perfect for educators, students, and hobbyists who want to dive into sensor-based projects. With easy-to-follow instructions, you can start building interactive systems and gain hands-on experience in electronics.
  • Versatile and Expandable: The included sensors cover a wide range of applications, from environmental monitoring (temperature, humidity, air quality) to motion detection and light sensing. This makes the kit highly versatile, allowing for endless customization and experimentation in various fields such as home automation, robotics, and IoT.
  • Complete Learning Platform: Along with the sensors, the kit includes access to a variety of resources, including tutorials and example projects, to help you get started quickly. You'll learn how to wire, program, and use each sensor to create interactive and responsive systems.
  • Perfect for DIY Projects: Whether you're building a weather station, a smart home system, or a motion-activated alarm, this kit gives you the essential sensors to create functional, sensor-driven projects. The Arduino Sensor Kit - Base is the perfect tool for hands-on experimentation, prototyping, and learning.
  • Confirm the board can run the tutorial’s Arduino sketch and use the specified pin arrangement.
  • Check that the ultrasonic sensor’s power and signal interface match the board and the code.
  • Make sure you have a breadboard, jumper wires, and USB connection suitable for your board.
  • Choose LEDs and current-limiting resistors based on the LEDs’ electrical specifications.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.