Have you ever wondered how simple thermometers work? Have you also ever wondered how Semiconductors work at different temperatures? Then this is the guide for you!
What you will need:
1. Basic Stamp (I am using the Basic Stamp Homework Board in this example, but most should work)
2. Diode (Any regular old cheap diode should work. I'm using a 1N4148 which can be easily obtained at Radio Shack
3. (Optional, but recommended) Piezoelectric Speaker (Comes with Basic Stamp in most cases)
Let's get started!
Step 1: Connect the Parts
1. Plug a diode into Pin 7 (with the black side facing the pin) and connect a wire from the other end of the diode to Vss.
2. Plug a Speaker into Pin 1, and connect a wire from the other end of the speaker to Vss as well.
You're done! Now time to program the chip.
Step 2: Programming the Chip
The code is fairly simple. What we want to do is measure RCTIME and send the result through the Serial Cable and send the raw data to the Speaker.
Here is the raw code that I am using, but feel free to change it around:
RC PIN 7
Spkr PIN 1
result VAR Word
HIGH RC ' charge the cap
PAUSE 1 ' for 1 ms
RCTIME RC, 1, result ' measure RC discharge time
DEBUG HOME, DEC result ' display value
FREQOUT Spkr, 30, result
If you don't have the BASIC Stamp Editor, it can be downloaded from Parallax Inc.
When you are done, download the code to the BASIC Stamp and you should hear a tone!
Step 3: Experiments/How It Works
Try putting your basic stamp in front of an Air Conditioner or in a fridge and you will hear the pitch increase.
Try putting the Diode near a stove top on low heat and you should hear the pitch decrease.
How does it work?
A Diode is a very basic semiconductor. When a semiconductor is cooled down, the electrons inside of it have a harder time flowing through it, so resistance is increased. The opposite is true when it is warmed up, the electrons have an easier time moving through the semiconductor. So this leads to the question, why does the pitch get higher when it is cooled?
RCTime is a function designed to measure the time it takes for a capacitor to discharge through a resistor. the more resistance there is the longer it takes the capacitor to discharge, so the larger the time. The bigger the number gets, the higher the frequency becomes from the speaker.
I'm not too sure how it works in detail, but I assume the Diode has some form of capacitance as all electronics do to some minor degree.
So as you can see, a diode can become a simple Thermometer. As I have stated before, feel free to modify any of the code or circuits to fit your needs! Hope you enjoyed!