Arduino Basic Input Output Circuits
Analogue IN - Reading a analogue input value from a Temperature Sensor
This example shows you read an analogue input from a temperature sensing device and switch an output.
This example also integrates the Digital Out LED example.
This example introduces the Serial communications for monitoring back at the PC, as well as using helper functions to structure the code.
Again my specific hardware is the Arduino Duemilanove platform, but the concept is the same regardless of the exact platform.
Before continuing make sure you have read and understand the warning notice here.
1x Temperature Sensor (TMP36)
1x Resistor (560Ohm)
In this example, the output (an LED) will be switched on and off in response to a given analogue input from a temperature sensing device.
The temperature sensing device in this example is a TMP36.
The TMP36 will give a fixed voltage rise per temperature sensing division, 10mV per 'C. It has a range of -40'C to +125'C and the voltage is calculated using the formula:
voltage = (temperature in 'C * 10mV) + 500mV
The Arduino has 10bit resolution on the analogue input, so will provide a value in the range 0-1023 relative to the 0 to 5V input capability of the analogue in. With this information it is easy to then construct functions to be used in the code.
The analogue input pin will be analogue In 3
The digital output pin will be digital pin 7
This circuit diagram for this example is shown below;
The following code is used to control the LED in response to the varying temperature seen by the TMP36. The code also include a deadband reset function similiar to that introduced in Example 3b. Load it into the development environment and upload it to the Arduino. Once uploaded and running, open a serial monitor window in the development environment to read back the serial communications.