Temperature Sensor Arduino Circut
For my final summative I created a temperature sensor that has leds that change depending on the temperature of the room. If you also want to create this follow my steps to get started!!!
Supplies
These are the items that are mandatory for you to complete this circut. If you want it to be more tidy you can also use tape or hot glue to keep the wires together instead of going around everywhere.
-Arduino uno
-breadboard
-jumper wires
-3 330 omh resistors
-3 leds
-temperature sensor
ARDUINO CONNECTIONS
After collecting your materials connect all your wires in the arduino uno since it will make it a lot easier to go step by step if you start off like this. If you want to be more organised you can color code the wires to make it more tidy you can also tape the wires together.
BREADBOARD CONNECTIONS
After plugging everything into the arduino uno wires into the breadboard the leds should light up. If they didnt you did somthing wrong and you need to recheck your connections. After checking your connections check if the leds are on corresponding to the temperature of the room. If all the leds are on make sure to check if your code is running.
CODE
now you can start making your code. or you can use the code I have provided.
int baselineTemp = 0;
int celsius = 0;
int fahrenheit = 0;
void setup()
{
pinMode(A0, INPUT);
Serial.begin(9600);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
}
void loop()
{
baselineTemp = 40;
celsius = map(((analogRead(A0) - 20) * 3.04), 0, 1023, -40, 125);
fahrenheit = ((celsius * 9) / 5 + 32);
Serial.print(celsius);
Serial.print(" C, ");
Serial.print(fahrenheit);
Serial.println(" F");
if (celsius < baselineTemp) {
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
}
if (celsius >= baselineTemp && celsius < baselineTemp + 10) {
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
}
if (celsius >= baselineTemp + 10 && celsius < baselineTemp + 20) {
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
}
if (celsius >= baselineTemp + 20 && celsius < baselineTemp + 30) {
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
}
if (celsius >= baselineTemp + 30) {
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
}
delay(1000);
}
After pasting the code into the aruino software the leds should light up corresponding to the temperature of the room. If they have not lit up somthing might be wrong with your connections or temperature sensor. If you want to increase the temperature to check if it works you can grab it with your fingers to warm the temperature sensor up.