6

I built a simple clock using a 4 digits 7 segments LCD display. I display one digit at a time, switching on and off very quicky and cycling through digits.

Everything is ok, but I used 8 + 4 = 12 arduino pins. I need 2 more pins for other features and I don't want to use 0 and 1 as I need onboard programming features of Arduino Mini.

I used I2C for RTC clock, I could add some interface here (like a PCF8574) and get some pins from here. But I'd like a different (and more educational, for me) approach.

Is there an IC that sends an HIGH output on one of four output pins driven by 2 input pins? I need this:

IN     OUT
P0 P1  D0 D1 D2 D3
0  0   1  0  0  0
0  1   0  1  0  0
1  0   0  0  1  0
1  1   0  0  0  1

This way I can connect OUT to digit selection and spare 2 pins.

Thanks for your hints.

Ghigo
  • 163
  • 1
  • 5

4 Answers4

3

I know it's not what you asked, but you're using a lot of pins, why not try streamlining them and go to an I2C backpack? This one from adafruit includes a single 4x7 segment display.

given your comment, another option would be an I2C/SPI 7 Segment driver. (datasheet).

new edit: Actually, when I posted the above 7 segment driver, this is the one I was thinking of. I don't know why I didn't find this the first time.

max7219/7221 datasheet and digikey source:

Madivad
  • 1,372
  • 8
  • 26
3

Are you using your analog pins? Did you know they can be used as digital pins?

The analog pins can be used identically to the digital pins, using the aliases A0 (for analog input 0), A1, etc. For example, the code would look like this to set analog pin 0 to an output, and to set it HIGH:

pinMode(A0, OUTPUT);
digitalWrite(A0, HIGH);

This is your best bet if you aren't using all your analog pins.

Adam Davis
  • 678
  • 5
  • 7
2

A 2-to-4 line decoder should do what you need. I've used a 74HC139 with Arduino before, which contains two decoders in a 16-pin DIP.

There are lots of other options though. In the past, I've used an 8 bit serial-to-parallel shift register (74HC595) to control a 7 segment display. It effectively lets you control 8 (or more) outputs using only 3 pins on your microcontroller. You have to be careful of power requirements though. Most shift registers aren't able to drive such a display directly, but I was able to incorporate transistors quite easily to get around that.

Peter Bloomfield
  • 10,982
  • 9
  • 48
  • 87
2

An I2C IO expander might be your best bet. If your existing I2C device uses a different address, you may be able to put both devices on the same I2C bus. You would then use 0 additional pins compared to your current design.

John Walthour
  • 323
  • 1
  • 3
  • 8