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.

Yes, its possible.

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!

<p>question</p><p>ho do i adapt this code do add a second 595 so that i can drive the whole 4 digid display?</p>
<p>If you add a second 595, you will no longer need to use a pin from the ATtiny85 to control a digit. Nor will you need to use Q7 to turn a digit on/off. </p><p>This greatly simplifies things. You can find many great indestructibles on multiple 595s.</p><p>You can use four pins on the second 595 to control the four digits. For example, if you have the D1 connected to Q0 and D2 connected to Q1 etc. you could send: </p><p>shiftOut(dataPin, clockPin, MSBFIRST, 14);<br>shiftOut(dataPin, clockPin, MSBFIRST, SegDisplay); </p><p>This will turn off the first 3 digits and display only in the 4 digit.</p><p>Sending 14 is b0000 1110. Sending this first 'shifts' it into the second 595.</p>

About This Instructable




More by breagan22:ESP8266 WiFi OTA Remote File Management ESP8266 - NodeMCU - CPU Speed Test ESP8266 Irrigation Controller / Echo Alexa integration 
Add instructable to: