Energy Saving Classroom Temperature Regulation

This tutorial will explain how to construct and code a circuit to display different LED's depending on temperature. It will display blue if it is too cold, red if it is too hot, and green if its just right. This circuit is designed for saving energy within classrooms as the green LED displays temperatures most comfortable for adolescents. If the green LED is displayed, it means that the temperature within the classroom is comfortable and you should turn off any heating or cooling within the room. This will in turn save energy.

Step 1: Step 1: Gather Your Parts

To create this circuit, you will need;

Arduino board

Bread board

Jumper wires

3 220 resistors (red red brown)

3 LED's (blue red green is recommenced)

Temperature sensor (any should be fine)

Step 2: Step 2: Place the Parts

The parts should be placed as shown above, with the 3 resistors next to each other to the right of the temperature sensor.

Step 3: Step 3: Put in the LED's

The LED's should be placed 3 pins down from resistors right next to each other as shown in the picture.

Step 4: Step 4: Place the Wires

All that's left in the circuit is the wires. Place them as shown in the picture, with a wire connecting port 2 to the resistor on top of the blue LED, another wire connecting port 3 to the top of the resistor onto of the green LED, and a final wire connecting port 4 to the top of the resistor onto of the red LED.

Step 5: Step 5: the Code

The first part of the code is to put 'const int hot = 78;

const int cold = 70'. You can change the values depending on your preferences. I would suggest leaving the values between 70 and 78 degrees Fahrenheit, the most suitable and comfortable temperature for most adolescents. If you live in a hotter or colder country, you may change these numbers in the code to suit your needs, however, I recommend not going under 58 degrees or over 85. Insert the next bit of code. You can change the A2, 2, 3 and 4, if you are using different ports.

void setup() {

pinMode(A2, INPUT); //the temperature sensor

pinMode(2, OUTPUT); //the blue LED

pinMode(3, OUTPUT); //the green LED

pinMode(4, OUTPUT); //the red LED


The final part of the code should not change much from person to person. You can change the ports from 2, 3 and 4 if yours are different, put something different for the serial monitor to say or change else if (tempF >= hot/cold if you had for some reason put something else at the very start when setting the parameters for hot and cold.

void loop() {

float voltage = (sensor / 1024.0) * 5.0;

float tempC = (voltage - .5) * 100;

float tempF = (tempC * 1.8) + 32;

Serial.print("temp: ");


if (tempF < cold) { //this turns on the blue led if the temperature is below what you set as cold

digitalWrite(2, HIGH);

digitalWrite(3, LOW);

digitalWrite(4, LOW);

Serial.println(" It's Cold.");this will tell you in the serial monitor that the temperature is too cold


else if (tempF >= hot) { //this turns on the red led if the temperature is above what you set as hot

digitalWrite(2, LOW);

digitalWrite(3, LOW);

digitalWrite(4, HIGH);

Serial.println(" It's Hot.");//this will tell you in the serial monitor that the temperature is too hot


else { //this turns on the green LED if it is in between hot and cold

digitalWrite(2, LOW);

digitalWrite(3, HIGH);

digitalWrite(4, LOW);

Serial.println(" It's just right, turn off any cooling or heating");// this will tell you in the serial monitor that the temperature is good and you should turn off any heating or cooling



    • Tape Contest

      Tape Contest
    • Trash to Treasure

      Trash to Treasure
    • Arduino Contest 2019

      Arduino Contest 2019