Working on a project that requires a two digit display.
I wanted to use an ATtiny85 to collect temperature data from a sensor and display the results. Two digits are sufficient for this project.
I thought I would see if I could make this happen with parts I have on hand. specifically:
1 - Arduino Uno
1 - ATtiny85
1 - 74HC545 shift register
1- 4 digit 7 segment LED SM420564
1 - potentiometer (simulate data from a temp sensor)
assorted capacitors, resistors and a NC switch.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: The Problem and Solution
I will need to alternate the two digits and display the 'tens' digit on one display and the 'ones' on the second.
The ATtiny85 attached to a shift register still does not have enough I/O pins to drive two seven segment displays independently and collect data from a sensor.
The shift register requires three pins from the ATtiny for data. Another pin is needed to collect data from a thermistor or, in my test setup a potentiometer.
This leaves one pin available to control the display digits.
It is possible to set the fuse for the Reset pin and use that for another I/O, however, that seems cumbersome.
In lieu of a relay or a second shift register, I will need two control pins to turn the two digit displays 'on' and 'off', timed alternately as the shift register sends the eight bit number.
I decided to use the one available pin on the ATtiny to turn off the 'tens' digit when displaying the 'ones'.
Now I need a way to turn the 'ones' digit off when the 'tens' number is sent over.
Since my display is only using seven segments, A to G, I have an extra output pin on the shift register. The Q7 pin, pin 9.
I have assigned:
Q0 to A
Q1 to B
Q2 to C
Q3 to D
Q4 to E
Q5 to F
Q6 to G
I'm using Q7 as a switch to turn the 'ones' on and off. By setting this bit LOW/HIGH I can turn the 'ones' LEDs on/off.
Step 2: The Sketch
I used a sketch from Benjo Charlie as a starter point.
Sending the register 128 or b1000 0000 sets the pin Q7 HIGH. A HIGH signal will turn the LED off. Sending anything 127 or less b0111 1111 will leave the PIN LOW and provide a ground for the LED.
As an example, to send a numeral 1 to the display we need to send 6 or b0000 0110 this will set pins D1 and D3 to HIGH. This is great for the 'ones' digit, however for the 'tens' digit, we need to turn the 'ones' off. By adding 128 to 6 we send 134 or b1000 0110. Now the Q7 is set to HIGH and the 'ones' digit is turned off.
The sketch loops and sends either a 'tens' digit or a 'ones' digit on each loop. Two loops are needed to display the complete two digit reading.
During the loop to display 'tens', the 'ones' digit is turned off (1 is placed on pin Q7) and the 'tens' digit is turned on. And, when the loop is sending the 'ones' digit, the 'tens' digit is turned off. ( HIGH signal sent to digit1pin ).
A small delay alternates the digits fast enough to make the changes indistinguishable to the eye.
The sketch is attached.
Hope you find this useful!