Advertisement

Thermistor and photoresistor — experimenting with heat and light. Comprehensive Arduino lessons.

Thermistor and photoresistor — experimenting with heat and light. Comprehensive Arduino lessons. Our store —

This lesson is about a thermistor and a photoresistor. We’ll burn to ashes and freeze to frost. We’ll make use of a motorized Gary the snail and make a robot cook some instant noodles. And as usual I’ll be explaining the easiest way possible, so everybody will be able to understand.

Here is a list of series, which I will add with the release of new lessons:
• LED, resistor and breadboard:
• What is PWM:
• What is ADC and how potentiometer works:
• Thermistor and photoresistor: You are here!

The electronics can work with electric signals only, it doesn’t “understand” anything else. But what about temperature? Or light? Those can be measured as well. There are some sophisticated components for that.

A thermistor is similar to that resistor that you already know. The main difference is that the thermistor’s resistance changes when heat or cold is applied.

For demonstrating resistance shifts I assembled this device. It measures the resistance and shows the value on the gauge. If the arrow comes close to the right side, to the mad resistor, the resistance is high, to the left side, to the sad resistor - it’s low.
There’s nothing connected to the contacts. But the value is off the charts showing very high resistance. There’s only air between the contacts, it does not conduct electricity. The contacts are installed in a plastic housing which does not conduct electricity either. That’s why it shows a high resistance value.

I connect a thermistor. The arrow jumps showing its resistance. Let’s try to heat the thermistor with a gas torch, the arrow goes to the left as the resistance drops. It’s low now. I put the gas torch away and wait. The thermistor cools and its resistance gradually increases. I take a piece of dry ice. It’s negative 78 point five celsius. I apply it to the thermistor. The arrow quickly starts leaning towards its right. A thermistor is equivalent to a resistor but if you apply heat the resistance decreases and if you cool it the resistance increases.

With the help of a thermistor, you could make some fragrant and delicious...instant noodles. We have a cup, a gas torch, and some water. I attach a thermistor to the side of the aluminum cup and set the temperature to 90 degrees. When the cup gets hot enough, Arduino activates the servo and pours the water in our lunch. Look. Here it is. The robot made instant noodles. Bon Appetit.

I assemble a circuit for using a thermistor. First I insert a thermistor in a breadboard. One leg in a positive and the other in a 12 bus. Now a resistor, one leg to the thermistor and the other to the other side of the breadboard. I connect the other resistor’s leg to the ground with a wire. Then a positive bus to Arduino’s 5 volt with another wire. A third wire couples the thermistor with A0 contact. An LED goes in a negative bus and bus 1. I put the resistor to the LED. Connect the resistor to Arduino’s contact 11 with a wire. The last wire couple's a negative bus with Arduino’s ground. All there’s left to do is write a program.

The first line sets pin 11 - the one with the LED - as output. The second line creates a box titled “Sensor” in Arduino’s memory. The third command reads the ADC value and puts it in the box “Sensor”. The values read by the ADC may range from 0 to 1023. The fourth line creates a box “Brightness”, there it stores numbers from 0 to 255, they affect the LED’s brightness. The fifth command seems very big but it’s very simple. It translates the number from one range to another.

The ADC we have has 1024 stages. The command shrinks it down to 256. Here. 1023 is now 255. This way the command MAP takes a number from one range and looks for a corresponding number in another range. The final command launches PWM on pin 11.

I heat up the thermistor with a gas torch and LED’s brightness increases. And when I apply a piece of dry ice and cool the thermistor the brightness decreases.

A photoresistor! Just like a thermistor, it has adaptive resistance. But it reacts to light rather than heat. The resistance is very high in the dark and low in the light.
I couple the photoresistor to the same circuit. I just detach the thermistor and insert the photoresistor instead. Arduino doesn’t care where the resistance comes from - light or heat. The ADC sees the changes in electricity and converts the analog signal into digital. So it can turn your lights on or central heating, or even press a nuclear launch button - whatever you program it to.

I make some alterations in the code, interchange 0 and 255 in the same code fifth command. The LED works the other way around, the more light there is on the photoresistor the dimmer the LED. The less light there is the brighter the LED.

#comprehensivelessons #arduinofordummies #amperka #arduino

thermistor,photoresistor,adc,Gary the snail,analog to digital,analog signal,digital signal,pwm,pulse-width modulation,graphite,video lessons,arduino,lessons,programming,diy,electronics,arduino uno,arduino windows,for dummies,amperka lessons,101,Arduino IDE,microcontroller,С++,LED,brightness,voltage,arduino.cc,arduino.org,lesson 4,coding,math,windows,hardware,software,flashlight,step by step,signal,tutorial,current,arduino tutorial,how to,ide,code,

Post a Comment

0 Comments