10% Off For Your First Order, Code:Elephant10



Arduino Project: A Cup with Temperature Indicator

Posted by Fiona Su on

thumb

Introduction:
Today, we will use Arduino to make a temperature-indicated cup. First, let’s design the circuit. When the LM35 temperature sensor senses different temperature, different LED will be turned on representing the temperature.
Hardware Required:

  • Arduino Board *1
  • USB Cable *1
  • Red M5 LED*1
  • Yellow M5 LED*1
  • Green M5 LED*1
  • 220Ω Resistor*3
  • LM35 Temperature Sensor *1
  • Breadboard *1
  • Breadboard Jumper Wire*7

Connection for REV4:

thumb

Connection for Arduino Mega 2560 R3:

thumb

Sample Code:

void setup() {
Serial.begin(9600);
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
}
void loop() {
  int vol = analogRead(A0) * (5.0 / 1023.0*100);   // read temperature value of LM35
Serial.print("Tep:");
 Serial.print(vol);
 Serial.println("C");
if (vol<28)                     // low temperature area and LED setup
{
  digitalWrite(13, HIGH);
  digitalWrite(12, LOW);
  digitalWrite(11, LOW);
}
else if (vol>=28 && vol<=30)                            
 {
   digitalWrite(13, LOW);

  digitalWrite(12, HIGH);
  digitalWrite(11, LOW);
}
else if (vol>30)                               //  low temperature area and LED setup

{
   digitalWrite(13, LOW);
  digitalWrite(12, LOW);
  digitalWrite(11, HIGH);
}
}

Result:
Corresponding LED will be turned on in accordance with corresponding temperature range.

0 comments

Leave a comment

Please note, comments must be approved before they are published