In this project you will be making a circuit that will take in your temperature and output and LED indicator.
This is similar, but not exactly the same as the Love-o-meter project in the Arduino project book.
What you will need
Eight long wires. One red and one black
Small wires
Five 220-ohm resistors
Five LEDs. Ideally all one color
Wire up your circuit like the following:
MAKE SURE YOUR POWER AND GROUND ARE HOOKED UP CORRECTLY. THE TEMP SENSOR MUST HAVE THE ROUNDED PART FACING AWAY FROM THE ARDUINO IF ORIENTED LIKE THE DIAGRAM! IF YOU DO NOT SET THIS UP CORRECTLY YOU WILL BURN YOURSELF!
What is different
For clarity we are going to start labelling our pins to add clarity to our program. Since the pin numbers will not change we will declare them as constants before our void setup()
In our setup we will begin the serial monitor as well as set all LEDs to OUTPUT and turn them off.
Inside the loop we will read in the temperature from the temperature sensor, which will read a value between 0 and 1023. We will convert the value to voltage with a calculation, and then convert the voltage to degrees Celsius. We will print all of this info to the serial monitor.
Next we will establish a baseline temperature. 20.0 oC is good to start. You may want to adjust this number later if need be.
We will also code in the compound conditional statements that will determine which lights stay on. The full loop will look like:
You can open up a multiline comment below your code like so:
In your Arduino program and under your code inside a multi-line comment please answer the following questions
What is the advantage of naming your pins?
What is the difference between the Serial.print and the Serial.println function?
Why do you think you need to divide by 1024 and then multiply by 5 when converting an analog read to a voltage?
If you are unable to get all of your LEDs to turn on by touching the sensor, what could you change in your code to get it working? There are two possible answers.
Scoring
Answer question 1 fully and correctly 15%
Answer question 2 fully and correctly 15%
Answer question 3 fully and correctly 30%
Answer question 4 fully and correctly 30%
Total 90%
Extension
Instead of declaring all the pins you can save time with a “for loop”. Research how to implement a for loop and add it in to your code. You may want to look at the similar Love-o-meter in the project book for help.
New Total 100%