Go Down

Topic: 4 Bits Digital Tube LED Display Module library (Read 2274 times) previous topic - next topic

jwz104

I bought an 4 bits display from aliexpress, this is the link: http://nl.aliexpress.com/item/J34-Free-Shipping-4-Bits-Digital-Tube-LED-Display-Module-Four-Serial-for-Arduino-595-Driver/32401419391.html

But I can't find a single library.
Most 4bit 7 segment displays have only VCC, GND, DIO and CLK.
But I have VCC, GND, DIO, RCLK, SCLK.

So I can't use the TM1637 lib because mine has different connections(I think).

Does anyone has a working lib for my display?

Paul__B

OK, well just for you! :smiley-eek:

Here is the link to the information.  Only took me an hour of searching. :smiley-roll:

The code to demonstrate it (from that link):
Code: [Select]
unsigned char LED_0F[] =
{// 0 1  2   3 4 5  6   7 8 9  A   b C    d  E    F    -
  0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0x8C,0xBF,0xC6,0xA1,0x86,0xFF,0xbf
};
unsigned char LED[4]; //用于LED的4位显示缓存
int SCLK = 2;
int RCLK = 1;
int DIO = 0; //这里定义了那三个脚
void setup ()
{
  pinMode(SCLK,OUTPUT);
  pinMode(RCLK,OUTPUT);
  pinMode(DIO,OUTPUT); //让三个脚都是输出状态
}
void loop()
{
  LED[0]=1;
  LED[1]=2;
  LED[2]=3;
  LED[3]=4;
  while(1)
  {
    LED4_Display ();
  }

}

void LED4_Display (void)
{
  unsigned char *led_table;          // 查表指针
  unsigned char i;
  //显示第1位
  led_table = LED_0F + LED[0];
  i = *led_table;
  LED_OUT(i);
  LED_OUT(0x01);
  digitalWrite(RCLK,LOW);
  digitalWrite(RCLK,HIGH);
  //显示第2位
  led_table = LED_0F + LED[1];
  i = *led_table;
  LED_OUT(i);
  LED_OUT(0x02);
  digitalWrite(RCLK,LOW);
  digitalWrite(RCLK,HIGH);
  //显示第3位
  led_table = LED_0F + LED[2];
  i = *led_table;
  LED_OUT(i);
  LED_OUT(0x04);
  digitalWrite(RCLK,LOW);
  digitalWrite(RCLK,HIGH);
  //显示第4位
  led_table = LED_0F + LED[3];
  i = *led_table;
  LED_OUT(i);
  LED_OUT(0x08);
  digitalWrite(RCLK,LOW);
  digitalWrite(RCLK,HIGH);
}

void LED_OUT(unsigned char X)
{
  unsigned char i;
  for(i=8;i>=1;i--)
  {
    if (X&0x80)
    {
      digitalWrite(DIO,HIGH);
    }  
    else
    {
      digitalWrite(DIO,LOW);
    }
    X<<=1;
    digitalWrite(SCLK,LOW);
    digitalWrite(SCLK,HIGH);
  }
}

Note that this is a particularly bad design, breaking many rules we explain here.  It (you can tell from the item description) uses not the TM1637 but two overloaded 74HC595s and requires your code to continuously perform all the multiplexing.

Lotsa luck!


zenoaghaz

try this: https://github.com/kostarev/TM74HC595-4dig-display

Go Up