How to use multiple TM1637 displays with a demultiplexer

Hello all,

I'm trying to create the Back to the future clock based on this project Great Scott! DeLorean-Inspired Time Circuit Clock with Adafruit gear! « Adafruit Industries – Makers, hackers, artists, designers and engineers!

I don't use i2c displays but TM1637 displays. I would like to keep the same logic to control the displays with a 74HC138N demultiplexer.

#include <Wire.h>
#include <TM1637Display.h>

#define CLK_PIN 6
#define DIO_PIN 5

#define E0 2
#define E1 3
#define E2 4

TM1637Display display[2] = {TM1637Display(CLK_PIN, DIO_PIN),TM1637Display(CLK_PIN, DIO_PIN)};

void setup() 
{
  Serial.begin(9600);
  
  pinMode(E0, OUTPUT);
  pinMode(E1, OUTPUT);
  pinMode(E2, OUTPUT);

  digitalWrite(E0, LOW);
  digitalWrite(E1, LOW);
  digitalWrite(E2, LOW);

  display[0].setBrightness(0);
  display[0].clear();

  digitalWrite(E0, HIGH);
  digitalWrite(E1, LOW);
  digitalWrite(E2, LOW);

  display[1].setBrightness(0);
  display[1].clear();
}

void loop() {

  digitalWrite(E0, LOW);
  digitalWrite(E1, LOW);
  digitalWrite(E2, LOW);
  
  display[0].showNumberDecEx(123,0, true);

  digitalWrite(E0, HIGH);
  digitalWrite(E1, LOW);
  digitalWrite(E2, LOW);
  display[1].showNumberDecEx(456,0, true);

  delay(1000);
}

I plugged the DIO input on the same line and the CLK on each outputs of the demultiplexer. Unfortunately it doesn't work. I read that it could be possible to use the same CLK signal and DIO signal different. So I plugged the the DIO on the outputs of the demultiplexer, but still not working.

So I'm a bit lost, I've tried to plug i2c displays instead of the TM1637 to confirm the electronic assembly and components and it works.

If someone has an idea, explanation, I'm all ears.

Thanks you and sorry for my English but I'm French.

1 Like

74HC138N output pins are active LOW, all inactive output pins are HIGH. It work OK with I2C but is it compatible with your design ?

Edit : maybe you can compare direct commands and "through 74HC138N" commands using a (virtual) Logic Analyser

Show us good images of the actual displays that you have.

Why use it for this application? Using 2 separate clock lines would do the job, and save I/O pins.

even more, whole "Back-To-The-Future" display can be controlled by single arduino without any additional parts

Thank you for your answers.

For my project I want to use 3 i2c 14 segment displays for months (with different address) and 9 TM1637 displays (3 red, 3 yellow and 3 green) for each color 1 for the year, 1 for the day and 1 for the time.
My idea was to control 8 display with the demultiplexer and 1 more Arduino output for the ninth display.

I want to save the Arduino outputs because I also use a RTC and LED (AM/PM). I could use only 3 outputs to control 6 LEDs with cd4069be (inverter)

My current example is only to test and understand the principle with 2 displays.

According the data sheet, it's similar as i2c without address. So, even if inactive outputs are HIGH, to control the display, the signal should change from low to high etc.. The input signal is the same on the selected output

I'm gonna check Logic Analyzer, thank you

i don't understand, you want on each display show AM or PM, but this mean it is only 1 wire, if it HIGH then lighting 3 "AM" LEDs and if LOW then opposite connected 3 "PM" LEDs, or what?

UPD: addresable through-hole 5mm LED can do it without resistors and transistors...

You actually don't need the inverter. As the Arduino Uno has the same continuous 20mA sink and source capabilities, you can connect one LED to 5V through a resistor and the complementary LED to GND through an other identical resistor.

Thank you!! It works well, it's smart, I didn't think about this possibility.

After some long hours to try to understand, to test. I changed the library by this one GitHub - AKJ7/TM1637: TM1637 Library Driver for Microcontrollers and now it works.

Thank you for your help, I'm able to continue my project, I think I will post it when it will be finished.

I want to display different hours, that's why I can't use only one wire.

One thing to note though : based on the ATmega328P datasheet page 308/653 :


DC current through Vcc or Gnd pins shall not exceed 200mA.
It means :
internal consumption + sum of all HIGH ouput pins < 200mA (current through Vcc pins)
and
internal consumption + sum of all LOW ouput pins < 200mA (current through Gnd pins)

=> a driver might be necessary for one or more LED pairs (upper and lower branch) (using the same trick if the driver allows current source and sink).

Only 3 pairs of Leds, 20mA each (that's 60mA total) shouldn't require any driver though.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.