Temperature Sensor In LED By Arduino

Introduction

 
In this article, I am going to explain the Temperature Sensor In LED By Arduino. I have fixed three LEDs in the Breadboard and also connected the temperature sensor with the Arduino. I will use the display on the LED.
 
Parts Of Lists
  • Arduino Uno
  • DS18B20 Temperature Sensor 
  • LEDs
  • Bread Board
  • Hook-Up Wires 

DS18B20 Temperature Sensor

 
The DS18B20 communicates over a 1-wire bus that, by definition, requires only one data line (and ground) for communication with a central microprocessor. Additionally, the DS18B20 can derive power directly from the data line (“parasite power”), eliminating the need for an external power supply.
 
 
Figure1: Sensor
 
 
Figure2: Water Proof
 
Connection
 
Connect the 3 LEDs in the correct pin mode. These three LEDs in the positive side to being connected in the input mode. The three negative sides are to be connected in the GND mode.
 
Temperature Sensor
  • Connect the three-pin in the VCC, GND, VIN
  • GND-Gnd 
  • VCC-5v
  • VIN- Input mode
Programming
  1. #include < OneWire.h >   
  2. #include < DallasTemperature.h > int greenLedPin = 2;  
  3. int yellowLedPin = 3;  
  4. int redLedPin = 4;  
  5. int temp_sensor = 5;  
  6. float temperature = 0;  
  7. int lowerLimit = 15;  
  8. int higherLimit = 35;  
  9. OneWire oneWirePin(temp_sensor);  
  10. DallasTemperature sensors( & oneWirePin);  
  11. void setup(void) {  
  12.     Serial.begin(9600);  
  13.     //Setup the LEDS to act as outputs    
  14.     pinMode(redLedPin, OUTPUT);  
  15.     pinMode(greenLedPin, OUTPUT);  
  16.     pinMode(yellowLedPin, OUTPUT);  
  17.     sensors.begin();  
  18. }  
  19. void loop() {  
  20.     Serial.print("Requesting Temperatures from sensors: ");  
  21.     sensors.requestTemperatures();  
  22.     Serial.println("DONE");  
  23.     temperature = sensors.getTempCByIndex(0);  
  24.     digitalWrite(redLedPin, LOW);  
  25.     digitalWrite(greenLedPin, LOW);  
  26.     digitalWrite(yellowLedPin, LOW);  
  27.     Serial.print("Temperature is ");  
  28.     Serial.print(temperature);  
  29.     //Setup the LEDS to act as outputs    
  30.     if (temperature <= lowerLimit) {  
  31.         Serial.println(", Yellow LED is Activated");  
  32.         digitalWrite(yellowLedPin, HIGH);  
  33.     } else if (temperature > lowerLimit && temperature < higherLimit) {  
  34.         Serial.println(", Green LED is Activated");  
  35.         digitalWrite(greenLedPin, HIGH);  
  36.     } else if (temperature >= higherLimit) {  
  37.         Serial.println(", Red LED is Activated");  
  38.         digitalWrite(redLedPin, HIGH);  
  39.     }  
  40.     delay(500);  
  41. }  
In this header file, it can be used to download from Google Chrome in the Git Hub and include in the Arduino software.
 
Explanation
 
In this article, I am explaining about the temperature as the Ice Bar and the water. LEDs will light up according to the changes. When the waterproof is fixed in the Water or Ice bar, it will be displayed in the serial monitor also.
 
Output