The leds show the temp between 16 to 40 c degrees.

Step 1: Shopping List

Step 2: Parts List

3 green led

2 yellow led

3 orange led

3 red led

11 330Ω resistors

1 breadboard

1 Arduino Uno

1 LM35 Temperature Sensor

15 jumper cables (male to male)

Step 3: Setup

<p>THX dude.</p>
<p>good job </p><p>(:</p>
<p>So does anyone know If this could used with batteries? Ive narrowed my code down to using only 1 led at a time but still think normal usage is out of the question.</p>
<p>Try this Code:</p><p>// Serial Temperature Sensor and visual output through LEDs</p><p>float temperature = 0; // store data in a variable with coma, temperature, whose value is initially &quot;null&quot;</p><p>//---------------------------------------------------</p><p>int analogPin = 0; // // initialize as input ANALOG read (the SENSOR's pin)</p><p>const int ledCount = 10; // the number of LEDs in the bar graph</p><p>int ledPins[] = { 1, 2, 3, 4, 5, 6, 7,}; // an array of pin numbers to which LEDs are attached</p><p>//--------------------------------------------------------------------------</p><p>//setup</p><p>void setup()</p><p>{</p><p>Serial.begin(9600); //open communication with the serial port</p><p>Serial.println(&quot;LM35 Thermometer &quot;); //print a starting message</p><p>analogReference(INTERNAL); // THIS FUNCTION IS REALLY IMPORTANT WHEN USING</p><p>// analogRead() INPUPTS. USING THE ANALOG INPUT, THE</p><p>// FUNCTION WILL RETURN VALUES FROM 0 TO 1023.</p><p>// The options for this function are:</p><p>//DEFAULT: the default analog reference of 5 volts</p><p>//INTERNAL: an in-built reference, equal to 1.1 volts</p><p>//EXTERNAL: the voltage applied to the AREF pin is</p><p>//used as a reference</p><p>//SINCE THE MAXIMUM VALUE THE SENSOR</p><p>//CAN HANDLE IS 1VOLT, WE HAVE TO USE &quot;INTERNAL&quot;</p><p>//INTERNAL ? means voltages of 1.1v or higher from the</p><p>//temperature sensor will give an analog reading of</p><p>//1023. Anything lower will give a lower value, e.g. 0.55</p><p>//volts will give 512. The sensor range is from 0C to 100C</p><p>//therefore 0C will be calculated when the sensor records 0volts</p><p>}</p><p>//function</p><p>void printTenths(int value) {</p><p>//printTenths function is used to show the fraction of the temperature reading 18,2C</p><p>Serial.print(value / 10); // prints a value of 123 as 12.3</p><p>Serial.print(&quot;.&quot;);</p><p>Serial.println(value % 100); //print the value after the decimal point &quot;write 100 for a 2nd digit precision 0,00[ch8243]</p><p>//---------------------------------------------------</p><p>// loop over the pin array and set them all to output:</p><p>for (int thisLed = 0; thisLed &lt; ledCount; thisLed++) {</p><p>pinMode(ledPins[thisLed], OUTPUT);</p><p>//--------------------------------------------------------------------------</p><p>}</p><p>}</p><p>void loop() { //this loop allows to reduce the error reading from analogig sensors (like the LM35) introducing an</p><p>//averaged value of the temperature, using the variable SPAN value 20. It means that 20 readings of</p><p>//the temperature are taken and than the output is divided by 20</p><p>int span = 20; //set up the number of readings</p><p>int aRead = 0; //store an initial value of 0 for the anaologic read</p><p>for (int i = 0; i &lt; span; i++) { //for 20 times do the following process</p><p>aRead = aRead+analogRead(analogPin); //read the analog from pin0 and sum it to 0(aRead)</p><p>}</p><p>aRead = aRead / 20; //average final value</p><p>//according to a simple mathematic proportion aRead : Temperature = 1023 : 100</p><p>//infact 1023 is the maximum analog value as well as 100 is the maximum analogic temperature</p><p>//The sensor is reading temperature according to Voltage variations (0 to 1Volts)</p><p>//therefore 0to1Volts corresponds to 0to1023 analogic values. But because we set up a function option</p><p>//calle &quot;INTERNAL&quot; (that assigs 1.1Volts to the maximum snalogic range 1024) it is required to</p><p>//write the following equation:</p><p>temperature = ((aRead*100*1.1)/1023)*10; // convert analog signal into temperature</p><p>//than we can print the temperature on the monitor together with the analogic value detected by the LM35</p><p>Serial.print(&quot;Analog in reading: &quot;);</p><p>Serial.print(long(aRead));</p><p>// print temperature value on serial monitor</p><p>Serial.print(&quot; - Calculated Temp: &quot;);</p><p>printTenths(long(temperature));</p><p>delay(1000); //time lag before next printed temperature</p><p>//---------------------------------------------------</p><p>// read the SENSOR:</p><p>int sensorReading = long(aRead);</p><p>// map the result to a range from 0 to the number of LEDs:</p><p>int ledLevel = map(sensorReading, 170, 270, 0, ledCount);</p><p>// loop over the LED array:</p><p>for (int thisLed = 0; thisLed &lt; ledCount; thisLed++) {</p><p>// if the array element's index is less than ledLevel,</p><p>// turn the pin for this element on:</p><p>if (thisLed &lt; ledLevel) {</p><p>digitalWrite(ledPins[thisLed], HIGH);</p><p>}</p><p>// turn off all pins higher than the ledLevel:</p><p>else {</p><p>digitalWrite(ledPins[thisLed], LOW);</p><p>}</p><p>//--------------------------------------------------------------------------</p><p>}</p><p>}</p>
<p>Nice arduino project. </p>

About This Instructable




More by YuvalS3:Ir Arduino Rciver  Arduino Temperature Led Bar 
Add instructable to: