Lear how to detect Temperature using Arduino with LM35 Electronic parts requirements. Arduino UNO/MEGA/PRO 3x LED 3x 220k Resistor 1x LM35 Temperature Sensor Jumper wires
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
/* . . ........ .... .. ...... ........ MMMM MMMMM MMMMMMMMMMMMMMMMMMM MMMMMMMMMM. MMMMMMMMM MMM.MMMMMMM MMM MMM .MM.MMM MMM ......... .... ... . . . MMM MMMMMMM . .MM. MM. MMM MM. . MMM MMMMMMMMM MMMM MMMMM.MM MM MMMMMMMMMMMM. .MMM MMM. .MMM.MMMMMMMMM ........ MMM MM . M .MMMMMMMM. MMM .MMM MMMMMMMM.MMMMMMM. MM .MMM. MMMMMMMM. MMM .MMMM MMMM MMMMMM. www.14core.com . ... . . ...... */ void setup() { pinMode(13, OUTPUT); pinMode(12, OUTPUT); pinMode(11, OUTPUT); //defines all the LED pins to output Serial.begin(9600); } void loop() { int vol = analogRead(A0) * (5.0 / 1023.0*100); //analog read the temperature sensor voltage Serial.print(" The temperature is:"); Serial.println(vol); if (vol<=31) //if the temperature is low { digitalWrite(13, HIGH); digitalWrite(12, LOW); digitalWrite(11, LOW); } else if (vol>=32 && vol<=40) // if the temperature is middle { digitalWrite(13, LOW); digitalWrite(12, HIGH); digitalWrite(11, LOW); } else if (vol>=41) //If the temperature is HIGH { digitalWrite(13, LOW); digitalWrite(12, LOW); digitalWrite(11, HIGH); } delay(100); } |
Download the source code here | 14COre Temprature Measuring