This is my first instructable, and I'll show you how you can interface a temperature sensor and a Dot-Matrix display with arduino in real time.
I have attached the arduino sketch, which is kinda big at a glance, but if you will go through the Instructable first then you'll understand the code without a glitch.
So, let's move.
Step 1: Parts Required
1. An Arduino of any kind
2. LM35 Temperature Sensor (you can use any other, but you'll have to change the temperature calculation algorithm in accordance with that)
3. An 8x8 Dot-Matrix Display (I am using 1088AS)
Also, if you have a 5x7 display, don't get disappointed, you just have to shift the binary values of each and every array in the sketch. Won't be a mess ;)
4. A MAX7219 IC
5. Resistor 1K and
6. Capacitor 10uF and 0.1uF
(you can remove parts in step 3 to 6 if you have an assembled module of MAX7219)
7. Breadboard (1 and if you are not using module then 2)
8. Connecting wires
Step 2: Connection
LM35 has simple configuration. As you can see in it's datasheet, centre leg goes to Arduino's A0, and the other two legs are for supply voltage.
And as for dot matrix part, I'll advice you to go through this Arduino's webpage first, http://playground.arduino.cc/Main/LedControl .
You'll understand every basic for interfacing Arduino with a MAX7129 LED driver.
If you are using breadboard, I have also uploaded the connection diagram of MAX7219 and Dot-Matrix Display.
Step 3: Understanding How It Works
There are several problems I faced while completing this project. I'll discuss them step-by-step, and their solutions also.
In turn they'll help you understand the Arduino sketch.
Step 4: Problem No. 1
First of all, when this idea came in my mind, I had my focus on displaying the numbers in the DMD (please don't mind, it's just my abbreviation for Dot-Matrix Display). For that I had to create several arrays, one for each number or digit. But temperature in degree Celsius have generally two digits and it'd be a very tedious job to create array for like if we have temperature range from 10*C to 40*C, then we have to create 31 arrays and that too not covers higher and lower temperatures. Then an idea came into my mind. I needed to separate the two digits, lowerbyte and upperbyte, and the question was: How to do that?
Suppose temperature is 27*C, now if we subtract 20 from 27, we get 7, if 34 just subtract 30, we get 4, and that's how we separate the lower byte.
For upper one, if temperature is 27*C upper byte is simply 2 and if temperature is 34*C lower byte is simply 3.
So, I created two functions, upperbyte() and lowerbyte(), which separates the upper and lower digits, so that I can display any temperature in range 0*C to 99*C.
Now how to display them in DMD?
Step 5: Problem No. 2
That's where second problem comes in. Now that I have separated the digits, I need to display them in the DMD.
So I decided to divide the DMD in two halves, the right one and the left one.
Separated upperbyte digit will be displayed in left part, and lowerbyte digit will be in right.
But I can only display either right side digit or left side digit at once
So now I have to create 20 arrays, 0-9 for the right side and 0-9 for the left side.
Step 6: Problem No. 3
If I can only display a digit at once, then how will I display 27 or 28 or 29 or anything having two digits?
To solve this problem, I used an idea from the concept of multiplexing.
Blink them enough fast so that human eye cannot differentiate whether they are blinking or not, and hence I used the delayMicrosecond() function in arduino.
And now I think all has been caught up, you can now move and upload the sketch to your arduino.
Step 7: Quick Tip
Make sure your temperature sensor is accurate. If your sensor reading changes every time, fast blinking will lead to absurd results in your dot matrix display. In my sketch, I calculate average reading of 10 readings and then display it
You can uncomment Serial communication functions anytime if you want to check in serial monitor whether program is separating upper and lower bytes correctly or not.
Got Stuck!? Just comment, I'll be happy to help :)
Also feel free to make any changes, and if that decreases the sketch length please let me know.