Arduino LED Temperature Indicator
by millerman4487 in Circuits > Arduino
65471 Views, 122 Favorites, 0 Comments
Arduino LED Temperature Indicator
Difficulty: e a s y .. Basic breadboard and programming skills
View this project on my website to see a cool simulation of the circuit!
This design is made to keep track of the temperature in a room.
You give it the parameters you want and it will light a blue LED if it is too cold, a red LED if it's too hot, and a green one if it's just right.
Get Parts
You will need:
- Arduino board: https://amzn.to/2DLjxR2
- Breadboard: https://amzn.to/2RYqiSK
- Jumper wires: https://amzn.to/2Q7kiKc
- 3 220Ω resistors (red-red-brown): https://amzn.to/2S2sV5R
- 3 LEDs (colors of your choice): https://amzn.to/2S5PFlM
- A temperature sensor (mine is an LM35, but most should work): https://amzn.to/2ORLHuQ
Make the Circuit
Wire it up:
- Red LED goes to digital pin 4 through one of the resistors and ground
- Green LED goes to digital pin 3 though a resistor and ground
- Blue LED goes to digital pin 2 through a resistor and ground
- Pin one (the pin on the left) of the temperature sensor goes to 5v
- Pin two (the pin in the middle) of the temperature sensor goes to analog pin A2
- Pin three (the pin on the right) of the temperature sensor goes to ground
-See the parts needed
Coding
Connect your Arduino to your computer and upload this code:
const int hot = 87; //set hot parameter const int cold = 75; //set cold parameter void setup() { pinMode(A2, INPUT); //sensor pinMode(2, OUTPUT); //blue pinMode(3, OUTPUT); //green pinMode(4, OUTPUT); //red Serial.begin(9600); } void loop() { int sensor = analogRead(A2); float voltage = (sensor / 1024.0) * 5.0; float tempC = (voltage - .5) * 100; float tempF = (tempC * 1.8) + 32; Serial.print("temp: "); Serial.print(tempF); if (tempF < cold) { //cold digitalWrite(2, HIGH); digitalWrite(3, LOW); digitalWrite(4, LOW); Serial.println(" It's Cold."); } else if (tempF >= hot) { //hot digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, HIGH); Serial.println(" It's Hot."); } else { //fine digitalWrite(2, LOW); digitalWrite(3, HIGH); digitalWrite(4, LOW); Serial.println(" It's Fine."); } delay(10); }
Open the Serial Monitor in the Arduino program, and watch what happens! You can also visit my website to see a simulation with a built-in serial monitor.