In this project, you will turn the Arduino into a thermometer! Use a temperature sensor to measure your skin temperature, and register the output with three LEDs. Even though the Arduino is a digital tool, it can interpret signals from an analog input, like the TMP36 temperature sensor, using the built in Analog-to-Digital (ADC) converter, accessed through the analog pins A0-A5, which you may have learned about in a previous lesson about analog input.
Explore the sample circuit embedded here by starting the simulation, clicking on the sensor, then dragging its temperature slider to adjust the simulated input and observe the resulting LED patterns.
In this lesson, you’ll build this simulated circuit yourself along side the sample. To optionally build the physical circuit, gather up your Arduino Uno board, USB cable, solderless breadboard, three LEDs, three alike resistors (any value from 100-1K, 220 ohms preferred), a TMP36 temperature sensor, and breadboard wires.
You can follow along virtually using Tinkercad Circuits. You can even view this lesson from within Tinkercad (free login required)! Explore the sample circuit and build your own right next to it. Tinkercad Circuits is a free browser-based program that lets you build and simulate circuits. It’s perfect for learning, teaching, and prototyping.
Step 1: Build the LED Circuit
Just as you’ve learned from the introductory lessons, start by wiring up your Arduino and breadboard with power and ground next to the example circuit, then add the the three red LEDs to the breadboard, as shown. These will be the indicator or “bar graph” lights for the project.
Drag an Arduino Uno and breadboard from the components panel to the workplane, next to the existing circuit.
Connect the 5 volt and ground pins on the Arduino to the power (+) and ground (-) rails on the breadboard with wires. You can change the wire colors if you want to! Either use the inspector dropdown or the number keys on your keyboard.
Drag three LEDs on the breadboard in row E, spaced 2 breadboard sockets apart. You can change the LED color using the inspector that pops up when you click on each one.
Use a 220 Ohm resistor to connect each LED’s cathode (left leg) to the ground rail (black) of the breadboard. In Tinkercad Circutis, you can change a resistor’s value by highlighting it and using the dropdown menu in the inspector.
Connect the LED anodes (right, longer legs) to digital pins 4, 3, and 2 on the Arduino. The LED anode (+) is the terminal that current flows into.
The cathode (-) is the terminal that current flows from. This connects to the ground rail.
Step 2: Add Temperature Sensor
A temperature sensor creates a changing voltage signal depending on the temperature it senses. It has three pins: one that connects to ground, another that connects to 5 volts, and a third that outputs a variable voltage to your Arduino, similar to the analog signal from a potentiometer.
There are several different models of temperature sensor. This model, the TMP36, is convenient because its output voltage is directly proportional to temperature in degrees Celsius.
In the circuits editor, find the temperature sensor in the components drawer.
Place the temperature sensor (TMP36) on the breadboard with the rounded part facing away from the Arduino, as shown in the figure (this is the default orientation).
Place the temperature sensor on the breadboard in row E, as shown.
Wire up the temperature sensor so the left pin connects to the 5V voltage rail, the center pin connects to A0 on the Arduino, and the right pin connects to the GND rail.
Step 3: Analog Input Observation
In the circuit schematic, you can see that the temperature sensor is connected to power (5 volts) and ground (0 volts) and the analog pin A0. As temperature rises, the pin connected to A0 increases its voltage. You can also see that three LEDs are each connected to their own digital pin.
Even though the Arduino is a digital tool, it’s possible for it to get information from analog sensors to measure things like temperature or light. To do this, you’ll take advantage of the Arduino’s built-in Analog-to-Digital Converter (ADC).
Analog-in pins A0 to A5 can interpret voltages between 0 and 5V, and translate that voltage to a value between 0 and 1023 for the Arduino sketch to use. The analog pins are primarily used to read information from sensors (but can also be used as digital outputs 14-19, unrelatedly).