At long last I set out to work on one of my Arduino projects when I realized that I didn’t have any 4-digit 7 segment LED display at home. Since it was quite important part of the project I went to ebay and started looking for something when I found this:
This is an “8-Bit LED 8-Bit Digital Tube 8-Bit Key TM1638”. It seemed to be a very good fit for my project since it not only had the display but it also had some buttons – something I needed too. In addition it had only three control lines which would simplify things a lot by sparing me from dealing with shift registers on my own – something I would have to do had I used the cheapest 7 segment LED display. When I got the board I got baffled a little bit. It was just a piece of hardware without any documentation. I deciphered the symbol on the chip and went for a quest to find some information about how it worked. I found a data sheet but it was mostly in Chinese. Unfortunately 我的中文不好, so I only skimmed it and continued looking. I quickly found that there is a library I could use. However I did want to learn how the thing I bought actually worked, so I spent some time more time looking for more information about the board. Finally, I found this page which turned out to be the most helpful and allowed me to start experimenting.
As I already mentioned the board has just 3 control pins plus power and ground. The control pins are strobe
, clock
and data
. The strobe
and clock
pins are only OUTPUT
while the data
pin can be both OUTPUT
and INPUT
. The strobe
pin is used when sending data to the board – you set the strobe
pin to LOW
before you start sending data – one or more bytes – and then set the strobe
pin back to HIGH
. Note that there is just one data
pin which means the data is being sent 1 bit at a time. This is where the clock
pin comes into play. When sending data you set the clock
pin to LOW
then you set the data
pin and set the clock
pin back to HIGH
to commit the bit value. You are probably already familiar with this pattern (if not take a look at this post) – it is the standard way of sending data with shift registers and therefore we can just use the standard shiftOut
function to send 8 bits of data with just one line of code.
The data sent to the board follow a protocol where the first byte tells the board what we want to do (I call it ‘command’) and is followed by zero or more bytes that are arguments for the selected function. Arguments are sent separately (i.e. the strobe
pin needs to be set to HIGH
after sending the command and again to LOW
before sending arguments). The board has 4 functions:
- activate/deactivate board and initialize display
- write a byte at specific address
- write bytes starting from specific address
- read buttons
To activate the board and set the display brightness we use the 1000abbb
(0x8?
) command where the bit marked as a
is used to activate/deactivate the board and bits marked as bbb
are used to set the brightness of the display. For example to activate the board and set the brightness of the display to the maximum value we need to send 0x8f
. This function does not have any arguments.
To write a byte at specific address we send the 010000100
(0x44
) command followed by the address in the form of 1100aaaa
(aaaa
bits denote the location we want to write to) followed by the value. For example to write the value 0x45
at address 0x0a
we would have to send the following sequence of bytes: 0x44 0xca 0x45
.
If we want to write values at consecutive addresses (very helpful to reset the board) we would send 01000000
(0x40
) followed by the starting address (again in the form of 1100aaaa
) followed by the values we want to write. For instance if we send 0x40 0xc0 0x00 0x01 0x02
0 would be written at address 0, 1 would be written at address 1 and 2 would be written at address 2. Note that we have 4 bits to select the address which means there are sixteen locations that can be written to. If you continue writing after reaching the address 0x0f
it will wrap and you will start again from address 0x00
.
To read buttons we send the 010000010
(0x42
) command, set the data
pin as INPUT
and read 4 bytes containing button status.
Command | Arguments | Description |
---|---|---|
0x8? (1000abbb) |
(none) | activate board (bit a ), set brightness (bits b ) |
0x44 (01000100) |
0xc? 0x?? |
write value 0x?? at location 0xc? (single address mode) |
0x40 (01000000) |
0xc? 0x?? 0x?? 0x?? |
write values 0x?? starting from location 0xc? (address auto increment mode) |
0x42 (01000010) |
N/A | read buttons |
Now we know we can write values to one of the 16 locations. This is the way we turn LEDs on and control the display. The board has two 4 digit 7 segment LEDs displays and 8 LEDs. Each of them has a dedicated address to which a value needs to be written to control the corresponding item. For instance if to turn on the first LED we would write 1 at address 0x01
. Below is a list of locations with short explanations.
Address | Description | 0x00 (0000) | display #1 |
---|---|
0x01 (0001) | LED #1 00000001 – red, 00000010 – green |
0x02 (0010) | display #2 |
0x03 (0011) | LED #2 00000001 – red, 00000010 – green |
0x04 (0100) | display #3 |
0x05 (0101) | LED #3 00000001 – red, 00000010 – green |
0x06 (0110) | display #4 |
0x07 (0111) | LED #4 00000001 – red, 00000010 – green |
0x08 (1000) | display #5 |
0x09 (2001) | LED #5 00000001 – red, 00000010 – green |
0x0a (1010) | display #6 |
0x0b (1011) | LED #6 00000001 – red, 00000010 – green |
0x0c (1100) | display #7 |
0x0d (1101) | LED #7 00000001 – red, 00000010 – green |
0x0e (1110) | display #8 |
0x0f (1111) | LED #8 00000001 – red, 00000010 – green |
(You might have noticed that according to the chart LEDs can be either red or green. I am cheap so I got the cheapest board I could find on ebay and it turned out it had only red LEDs so I was not able to test the green color.)
We now have all the information needed to breathe some life into the board. First we need to connect the TM1638 based board to our Arduino board. This is how I did it:
Arduino TM1638 based board 3.3V ------------------ VCC GND ------------------ GND PIN #7 ------------------ STB PIN #8 ------------------ DIO PIN #9 ------------------ CLK
The setup function needs to activate and reset the board. For readability I created a helper function for sending commands and a separate function for setup. Here is how the code to setup the board looks like:
const int strobe = 7; const int clock = 9; const int data = 8; void sendCommand(uint8_t value) { digitalWrite(strobe, LOW); shiftOut(data, clock, LSBFIRST, value); digitalWrite(strobe, HIGH); } void reset() { sendCommand(0x40); // set auto increment mode digitalWrite(strobe, LOW); shiftOut(data, clock, LSBFIRST, 0xc0); // set starting address to 0 for(uint8_t i = 0; i < 16; i++) { shiftOut(data, clock, LSBFIRST, 0x00); } digitalWrite(strobe, HIGH); } void setup() { pinMode(strobe, OUTPUT); pinMode(clock, OUTPUT); pinMode(data, OUTPUT); sendCommand(0x8f); // activate and set brightness to max reset(); }
Here is how this works. The code starts executing from the setup
function. First we set pins 7, 8, 9 as output pins. Next we activate the board and set the brightness to the maximum value by sending 0x8f
. Finally we reset the board by clearing all the memory locations. We do it by setting the board to the address auto increment mode (0x40
), selecting 0
as the starting address (0xc0
) and sending 0
sixteen times. Now that the board is ready to work with let’s display something. An easy thing to display will be 8.
in the first and last digit position on the display and light the 3rd and 6th LED. To do that we will use the single address mode since the locations we are going to write to are not consecutive. Our loop
function that does this looks as follows:
void loop() { sendCommand(0x44); // set single address digitalWrite(strobe, LOW); shiftOut(data, clock, LSBFIRST, 0xc0); // 1st digit shiftOut(data, clock, LSBFIRST, 0xff); digitalWrite(strobe, HIGH); digitalWrite(strobe, LOW); shiftOut(data, clock, LSBFIRST, 0xc5); // 3rd LED shiftOut(data, clock, LSBFIRST, 0x01); digitalWrite(strobe, HIGH); digitalWrite(strobe, LOW); shiftOut(data, clock, LSBFIRST, 0xcb); // 3rd LED shiftOut(data, clock, LSBFIRST, 0x01); digitalWrite(strobe, HIGH); digitalWrite(strobe, LOW); shiftOut(data, clock, LSBFIRST, 0xce); // last digit shiftOut(data, clock, LSBFIRST, 0xff); digitalWrite(strobe, HIGH); }
You can find the entire sample in the repo on github.
Displaying 8.
is cool but it would be even cooler if we knew the relation between the value sent to the board and what will be shown. The board is using the standard 7 segment coding, so the value sent to the board is a byte with bits coded as follows: [DP]GFEDCBA
. Each bit will light one segment as per the image below:
So, for instance if you wanted to display A
you would have to write 0x77
at the corresponding location.
Now we know how to control LEDs and the display. But there is one more thing the board offers – buttons. Reading what buttons are depressed works a little bit different from what we have seen so far. First we need to send the 0x42
command, then we set the data pin as an input pin. Finally we need to read 4 bytes from the board (bit by bit). The first byte contains status for buttons S1 (bit 1) and S5 (bit 4), the second byte contains status for buttons S2 (bit 2) and S6 (bit 5) and so on. If we |
(i.e. logical `or`) all the bytes we will end up having a byte where each bit corresponds to one button – if a bit set to one means that the corresponding button is depressed. Here is a little program (I omitted the setup – it is identical as in the first sample) where the board will light an LED over a button that is pressed.
uint8_t readButtons(void) { uint8_t buttons = 0; digitalWrite(strobe, LOW); shiftOut(data, clock, LSBFIRST, 0x42); pinMode(data, INPUT); for (uint8_t i = 0; i < 4; i++) { uint8_t v = shiftIn(data, clock, LSBFIRST) << i; buttons |= v; } pinMode(data, OUTPUT); digitalWrite(strobe, HIGH); return buttons; } void setLed(uint8_t value, uint8_t position) { pinMode(data, OUTPUT); sendCommand(0x44); digitalWrite(strobe, LOW); shiftOut(data, clock, LSBFIRST, 0xC1 + (position << 1)); shiftOut(data, clock, LSBFIRST, value); digitalWrite(strobe, HIGH); } void loop() { uint8_t buttons = readButtons(); for(uint8_t position = 0; position < 8; position++) { uint8_t mask = 0x1 << position; setLed(buttons & mask ? 1 : 0, position); } }
Again, you can find the entire example in my github repo.
These are the basic building blocks and you use them to build something more useful. Here is a video of a little demo project I built:
The code for this demo is also on github.
Enjoy.
[…] I was already familiar with the TM1638 (for more details see my recent post about using a TM1638 based board with Arduino) chip so I thought making the TM1637 work should be easy. Unfortunately, while there are some […]
LikeLike
Great post! Thanks
LikeLiked by 1 person
Very useful post. Thank you.
LikeLiked by 1 person
Thanks! I am glad you found it helpful.
LikeLike
Hi moozzyk, I have some troubles when implementing this with TivaC on Energia. As you may know the Energia library is designed for Arduino projects. I’ve implemented your full code on TM1638 successfully on Arduino but it didn’t work on Tiva C (LM4F123G). I compiled the code OK on Energia, upload it onto the chip OK, but nothing happens.
I stroll again and again around the code and found nothing which I can edit to make it run. shiftOut is simple, the rest is also simple, but why it didn’t work?
Could you try to implement this on Tiva C and Energia and give me some advice?
Thanks. Kha.
LikeLike
Hi Kha,
Thanks for your comment. Unfortunately, I have not played with Energia/Tiva C yet and it does not seem like I will be able to get to it anytime soon. I can’t promise anything but you can post your code somewhere on github and I can take a quick look.
Thanks,
Pawel
LikeLike
For the complete sketch download the one of the demo, behind the video. I had problems with the snippets but later understood.
LikeLike
[…] Article Arduino […]
LikeLike
I got this code working ‘as is’ with an ESP8266 too – thanks for the information.
The specification sheet says the TM1638 requires 5V +/- 10%, but mine’s working fine on a 3.3V supply.
I noticed a couple of corrections/clarifications;
The binary for 0x44 is 01000100 (not 10000100)
When sending out values in auto increment mode, you have to write out the ‘missing’ green LED values – I did a shiftOut(data,clock,LSBFIRST,0) – that wasn’t immediately obvious to me.
Lastly, I added some definitions in the code so that displaying numbers is easy:
#define SEGMENT_A 0x01
#define SEGMENT_B 0x02
#define SEGMENT_C 0x04
#define SEGMENT_D 0x08
#define SEGMENT_E 0x10
#define SEGMENT_F 0x20
#define SEGMENT_G 0x40
#define SEGMENT_DP 0x80
const unsigned char numbers[] = {
SEGMENT_A + SEGMENT_B + SEGMENT_C + SEGMENT_D + SEGMENT_E + SEGMENT_F, // 0
SEGMENT_B + SEGMENT_C, // 1
SEGMENT_A + SEGMENT_B + SEGMENT_G + SEGMENT_E + SEGMENT_D, // 2
SEGMENT_A + SEGMENT_B + SEGMENT_G + SEGMENT_C + SEGMENT_D, // 3
SEGMENT_F + SEGMENT_G + SEGMENT_B + SEGMENT_C, // 4
SEGMENT_A + SEGMENT_F + SEGMENT_G + SEGMENT_C + SEGMENT_D, // 5
SEGMENT_A + SEGMENT_F + SEGMENT_G + SEGMENT_E + SEGMENT_C + SEGMENT_D, // 6
SEGMENT_A + SEGMENT_B + SEGMENT_C, // 7
SEGMENT_A + SEGMENT_F + SEGMENT_B + SEGMENT_G + SEGMENT_E + SEGMENT_C + SEGMENT_D, // 8
SEGMENT_A + SEGMENT_B + SEGMENT_C + SEGMENT_F + SEGMENT_G, // 9
};
Thanks, Kevin
LikeLike
Thanks for pointing out incorrect binary values. I updated the post accordingly.
You are correct – in auto increment mode you have to write the values for green LEDs even if your board does not support green LEDs. I guess this is the matter of addressing.
For me it’s always hard to remember which segment is which 🙂
Thanks,
Pawel
LikeLike
Very useful post. Thank you.
LikeLiked by 1 person
A very useful and good post. I’ts not been too easy for me (not good C programmer) extract what I was looking for, but now I have more clear my mind on my board and your sketch.
You wrote the essential to explore all the capability of the device TM1638: this is more than enough.
But I have to add another positive note, because in your sketch, you haven’t used any library.
On other side, many other post that I’ve found and try, calls heavy library, often more heavy of my entire sketch.
So, instead of have the display handled by a small quantity of code, using the indicated library the memory amount for the display was bigger than my not short application.
With your code all this don’t happens, and furthermore I’m now able to cut the unnecessary parts, reducing the code to 5898 bytes.
This it’s been for me a one day school lesson.
Thank you.
LikeLiked by 1 person
Thanks a lot for your comment. I am glad you found the post useful!
LikeLike
Just a note: in the post there are some broken link. (delete this reply when you want).
LikeLike
Thanks for reporting – it’s been a while since I published this post. I will check the links.
LikeLike
“… Finally we need to read 4 bytes from the board (bit by bit). The first byte contains status for buttons S1 (bit 1) and S5 (bit 4), the second byte contains status for buttons S2 (bit 2) and S6 (bit 5) and so on. If we | (i.e. logical `or`) all the bytes we will end up having a byte where each bit corresponds to one button – if a bit set to one means that the corresponding button is depressed. …”
moozzyk, thank you for this information. You allowed me to develop code for my favorite processor to use these displays. I understand that this article is 3 or 4 years old now.
I’m not sure about your code, but the description above is not correct for the boards that I have recently purchased. I know sometimes we don’t get back to correcting the documentation.
I have found that the 4 bytes returned for the switch status all have the status in “bit1” and “bit5” assuming “bit1” is the LSB. So, the description should be: S1-bit1, S5-bit5; S2-bit1, S6-bit5 and so on.
I can’t exactly tell with your code, but to combine all the switch status bits into one status byte by ORing bytes with my code I have to shift the second, third, and fourth byte before the ORing to put them in the correct position.
Thanks for all your work on these projects! I still have lots to look at.
LikeLike
Hi Paul,
Looking at the code I think you might be right. In this line `uint8_t v = shiftIn(data, clock, LSBFIRST) << i;` the `<< i` is shifting the value after reading the byte so that it can later be OR'ed with already read values using '|'. If it was not like you say shifting would not be required. Thanks for pointing that out!
Pawel
LikeLike
Great stuff, got me started, thanks. I’ve put in place lookup tables for for ascii & hex, will probably wrap up as a ‘lite’ library – https://github.com/danja/dog
LikeLiked by 1 person
Hello moozzyk,
very special thanks for the explanations and all the detailed instructions. I was searching for a useful Arduino UI/HMI for further projects and found the LED&KEY. J was reading the datasheet and then your instructions, and 60s after unboxing this unknown piece of hardware I was able to control several LED and digits on the shield. Of course today there are well known developed libraries for this chip. But for understanding how it works it is very interesting to use your plain text examples. Thank you soo much , i makes a lot of fun to read this and helps a lot.
RBalasus
LikeLiked by 1 person
Hi readers,
FWIW there is a very good menu library available for the TM1638 at http://forum.arduino.cc/index.php?topic=351186.0. It provides functions, that with minimal coding, will allow you to used the buttons and display as an interface to your project.
Cheers
Frantech
LikeLike
Shameless plug (because you seem to be the author of the library…) I think you know that this article was written before you wrote your library. The idea behind this article was to understand the board and write kind of documentation that describes it because, at least at that time I wrote it, there was pretty much nothing available in English. Understanding how things really work is completely different than using a library and a lot of people really appreciate that they could learn all the details.
Thanks,
Pawel
LikeLike
[…] Quelle: Using a TM1638 based board with Arduino | Code, the Universe and everything… […]
LikeLike
Want to know whether Led&Key shield can be used on IOT2040. I tried it but unfortunately not working, though iot2040 is an arduino compatible. Appreciate if I can get some support on the interface.
LikeLike
I have not played with IOT2040 so don’t really know. I would think that if it is Arduino compatible then it should work.
Thanks,
Pawel
LikeLike
great instructions written in plain English, thank you.
LikeLiked by 1 person
Thank you for sharing this!
LikeLiked by 1 person
how I could adapt that code for the TM1618, I tried but the segments light up wildly, do not form the pattern they should form, any advice?
LikeLike
Unfortunately, I have not played with TM1618 and don’t know what the differences are so I can’t help here. Sorry!
Thanks,
Pawel
LikeLike
thanks in all the ways, you helped me a lot to understand the operation of the Tm1638, if I get progress I will share it
LikeLike
This is a good idea and is the best way to study, going to the deep of the argument and producing a report to be shared with other people.
LikeLike
I picked up the LED&KEY board as a cheap display for a costume I built. Your excellent program has allowed me to quickly setup multiple text scrolls without too much programming. I do have one question, since my Arduino skill are still very basic. Is there a way to have the program loop through just the counting and text scroll phase? I just need it to count, display a bunch of scrolling text, pause, then repeat. I believe you have some mechanism in there that stops the program from looping from the beginning but I can’t figure it out. Apologies as this may be a really dumb question.
LikeLike
If you don’t want the buttons part you can just add the following line just after the switch block `mode = mode % 1;`. This should result in disabling the buttons mode and the program will be switching the first two modes continuously.
Thanks,
Pawel
LikeLike
Perfect! Thank you. I’ll have to read up on the mode command to understand how it controls the looping.
LikeLike
Sorry, I have another question. I tried to add the line ‘mode = mode % 1;` in several different areas of the code and kept getting an error. Can you tell me the line number where I should insert it, so I can be sure it’s the right block. There are many switches, blocks and modes, and I’m a bit confused. Thanks.
LikeLike
You need to put it here: https://github.com/moozzyk/TM1638/blob/master/TM1638_demo/TM1638_demo.ino#L55
Only I just noticed a mistake – it should be `mode = mode % 2;` or `mode = mode & 1;` (either should work).
Not sure what error you got so hard to tell what did not work. Also there is only one `switch` block in the program.
LikeLike
The additional line works for blocking the buttons mode, but it also blocks out any additional commands I try to add (like controlling other LEDs)
Is there a way to completely eliminate the switching part of this code, so the counting and text scroll modes run as one big loop? That way I can add additional code above and below the sections you created. I understand the basic functions but the switching program you created has me very confused. I love the way your script runs without the need for a library, but the switching part is beyond my skills.
LikeLike
The program is just a demo so runs sequentially modes until it reaches the last one (buttons) which will be active for the rest of the time. Modes are numbered 0 (counting), 1 (scrolling), 2 (buttons). Modes 0 (counting) and 1 (switching) indicate completion by returning a boolean flag. Mode 2 is terminal so does not return any status because it never completes. The boolean values returned by modes 0 and 1 are implicitly converted to an integer value (false translates to 0, true translates to 1). This is why I add the return value to the mode variable. Note that by returning false (i.e. mode not completed) I just add 0 to the mode variable so nothing changes and the next time the switch block is entered the same mode is used. Two notes – the mode variable is static meaning it will be initialized only once and even if the function is entered later the variable won’t be re-initiailized (it could be changed to be a global value and the effect would be practically the same). The loop function is called continuously by Arduino.
You can definitely remove the switch block – e.g. you can remove the switch and the mode variable etc. altogether and just invoke buttons() from the loop(). The buttons() function is I think the closest to real life since it is handling buttons and scrolling the text at the same time.
Thanks,
Pawel
LikeLike
I’ve had more time to play with your code, and I’m really enjoying the way it’s structured. One question, if you don’t mind. I can see the counting() function returns after the “position” variable is greater than 8 (since it counts 0-9), but how does the scroll() function terminate and return? I know it has a FOR loop using a variable called “i”, but the logic really confuses me. I’ve added more lines of scrolling text and for some reason my code scrolls all the text one and a half times before it returns. Not sure what causes the loop to restart instead or return.
I’ve also tried to remove the whole 3 switch function, but ran into more confusion. There is only one delay statement in the program, so I know each line from the subprograms loops back through the main loop (otherwise you would have to add delays within the FOR loops). It’s the way the programs return to the main loop that is giving me issues.
LikeLike
scroll() has the index variable that is tracking the progress of displaying the scroll. Once the index is twice the length the text to scroll scrolling will terminate. This is the line does that that: `index = ++index % (scrollLength << 1);`. scrollLength << 1 is an equivalent of scrollLength * 2. Because of the % operator once the index reaches scrollLength * 2 the expression will evaluate to 0 which will results in returning true from the scroll() function (return index == 0;) which in turn tells the logic in the loop method to move to the next mode.
LikeLike
Dear Mujik, thanks a lot for your post !
I got induction cooker which have indication boar used similat LED driver – SM1628
But wiring\connection of LED digists itself is very strange,
drowing is here – https://cloud.mail.ru/public/9Z19/5T5oXqi4R
as you see they ise to connect LEDs to seg2 to seg 6, skip seg7, and continue seg 8 to seg10
i have no idea why they did so,
can you please help me to figure out how can use it
and main idea to make arduino emulation of this indication induction cooker board
cheers !
LikeLike
Hi Roman,
I am sorry but I don’t know why it is connected like this.
Thanks,
Pawel
LikeLike
Hi.
My opinion (maybe wrong) is that if we use a standard BCD counter and 7 segment decoder/driver, we also are forced to apply Seg1 to A, Seg2 to B, Seg3 to C, and so on….
But if we drive an array of segment /seven + DP) with a device as TMS1628, we are free to chose the pin to associate to every segment. This is because we work with a pattern that contains the High or Low in the bit-position that we prefer.
We are free.
Connect 1 to A, 2 to b and so on, we can anyway display on our seven segment digits meaningless character. We have to remember that with 8 bit we could show on every digit 255 pattern + a blank, but only 10 of these symbols are number.
I think that in your circuit, the PCB maker ask to the engineer to change some track, to have a simplest routing work.
This need to change the association bit-segment.
What you mind about my hypothesis?
Regards
LikeLike
Hii Iam trying to display the time in TM 1637 but the library is not supported please provide the library for 4 bit display TM1637 thank you.
http://bigbelectronics.in/product.php?product=4-bits-digital-tube-led-display-module-clock-display-tm1637-arduino-raspberry-pi
LikeLike
You can find a description of TM1637 here: https://blog.3d-logic.com/2015/01/21/arduino-and-the-tm1637-4-digit-seven-segment-display/
LikeLike
This was my initial how to that worked, thank you.
On to raspberry and python or C++, any info?
LikeLike
The basics won’t change. You will need to send similar signals to Raspberry GPIO pins. If you want to use Python you could use one of the available Python libraries (e.g. GPIO)
LikeLike
Hi moozzyk,
I have a LED display board which i took out from a Induction cooker board. It has TM1668 ic connnected and 3digit 7segment(+DP) connected. but the connection of these three digit are like this.
DIGIT1 OF 7SEGMENT-GRID4 OF IC
DIGIT2 OF 7SEGMENT-GRID2 OF IC
DIGIT3 OF 7SEGMENT-GRID3 OF IC
Similarly the segment pins are:
SegA OF 7SEGMENT-SEG1 OF IC
SegB OF 7SEGMENT-SEG8 OF IC
SegC OF 7SEGMENT-SEG3 OF IC
SegD OF 7SEGMENT-SEG5 OF IC
SegE OF 7SEGMENT-SEG4 OF IC
SegF OF 7SEGMENT-SEG2 OF IC
SegG OF 7SEGMENT-SEG6 OF IC
DP OF 7SEGMENT-SEG7 OF IC
So, pls give instruction how to programme this board to get the segment to light up. i can’t understand from the datasheet as your example TM1638 datasheet is completely different from my TM1668. Pls help me to get out from problem.
LikeLike
I have never used TM1668 so I don’t know. Sorry.
LikeLike
Pls have a look the datasheet of tm1668and 1628… If possible let me know how to use separate segment and separate digit pin..
LikeLike
Hi.
Maybe you can understand better an English DataSheet than a Chinese one, so please give a look at http://www.artschip.com/pdf/HT1668.PDF
Try to open this discussion to all the people, not only with Mozzly that could be a little busy.
Have luck.
LikeLike
How to open discussion in the forum. Pls
LikeLike
To use multiple TM1638 do you think you can share DIO and CLK across chips and have an independing stb for each chip?
For a TM1640 I share a DIO and use an individual clock, ut the STRB pin is a new one for me to comprehend.
LikeLike
Hi. I think that what are you writing it’s correct – if we referring to the description of the functions of the pins : http://www.microcontroller.it/Tutorials/Elettronica/componenti/tm1638.htm
It seem that the IC ignore CLK when STB still High.
LikeLike
In any case the name ‘STB’ is usually indicating a kind of ‘trigger’ for the device. Usually a device with the STB (strobe) pin, is regarding less that happens on the input pins (or pin), until the strobe (STB) is at the logical level for ‘off’. The device (the IC) get the state of the input pins only when STB change its status from ‘off’ to ‘on’. The ON state could be a LOW or an HIGH and this is specified by datasheet. Until the STB is in the active level, some devices remains ‘transparent’ until it return to the inactive level. This means that the input continue to change the output until STB return inactive. But in these cases the name STB it’s not the best and the manufacturers prefer ‘Enable’ or Chip Enable (CE or /CE). STB it’s usually a ‘flash’ that freeze the inputs into the device and probably on the outputs.
All this, without read the datasheet.
I suppose that in the device under our eyes, CLK make advance by one position the Data Input of the shift register, while the outputs still hold on the previous STB. When the serial input register is complete, after the right number of CLK, giving a STB, the device freeze on the outputs the new data present in the shift register and hold it until a new STB.
These are only my supposition based on the significative names of the IC pins.
LikeLike
Maybe your question has another way to be understood. In the cases of shift registers, they can be connected in series. This means that more devices with 8 bits can be connected together to form a longer shift register with 16 (or more) bits (and outputs.
If your question is falling in this case, CLK and STB are usually common, but DIO of the first Shift Register is connected to the source of data that are probably coming from an MCU, the DIO of the second Shift register is to connect to the Shift Data Out of the first one (and so on, depending by the length of the shift chain.
STRB will ‘freeze’ the shited data into all the shift registers in the chain that probably from that moment will shows to the outputs the data.
LikeLike
Hi moozzyk, i found ur code work perfectly in my TM1668 ic. But the system halt for 2-3minute and display completely vanished. Again the display comes after 3-4minute.what the problem can u pls tell
LikeLike
I don’t know, sorry. I have not seen anything like this.
LikeLike
Hi Chandra. I suppose that you are not using the TM1668 alone: true? So can we move our attention on the rest of your hardware and software?
LikeLike
Yes. I am using tm1668 with Arduino nano. Nothing else in the hardware. Iam using data, clock and strobe as digital pin 3, 4, 5 respectively. Thats it.
LikeLike
Yes. These complete informations are enough to be sure that the problem is surely inside Arduino nano or in its code.
LikeLike
Pls reply
LikeLike
Arduino nano is ok. And the code is the same code that i am using is same as moozy in here
LikeLike
The elements in question are:
1) Arduino MCU:
2) TM1668;
3) the connection between 1 and 2;
4) the code that you wrote inside Arduino.
If we suppose that are surely good the points 1) and 4), our suspicion falls on 2) and 3).
Whath elements remain to us for go more in deep if we don’t see the wiring neither code?
Anyway about the wiring we could have a bit of trust because your assembly can run (even if for few minutes).
The conclusion that I can reach still the same.
LikeLike
Thank you, Downloaded code and change IO for ESP8266 and it worked a charm 🙂
LikeLiked by 1 person
Thank you a lot for the precious information shared with us.
Your contribute change the sight of the future of the world.
LikeLike
I have a LED display board which i took out from a Induction cooker board. It has TM1668 ic connnected and 3digit 7segment(+DP) connected. but the connection of these three digit are like this.
DIGIT1 OF 7SEGMENT-GRID4 OF IC
DIGIT2 OF 7SEGMENT-GRID2 OF IC
DIGIT3 OF 7SEGMENT-GRID3 OF IC
Similarly the segment pins are:
SegA OF 7SEGMENT-SEG1 OF IC
SegB OF 7SEGMENT-SEG8 OF IC
SegC OF 7SEGMENT-SEG3 OF IC
SegD OF 7SEGMENT-SEG5 OF IC
SegE OF 7SEGMENT-SEG4 OF IC
SegF OF 7SEGMENT-SEG2 OF IC
SegG OF 7SEGMENT-SEG6 OF IC
DP OF 7SEGMENT-SEG7 OF IC
So, pls give instruction how to programme this board to get the segment to light up. i can’t understand from the datasheet as your example TM1638 datasheet is completely different from my TM1668. Pls help me to get out from problem.
LikeLike
Maybe your problem could be resolved reading English instead of Chinese DataSheet
https://www.sunrom.com/p/tm1668-soic24-led-displaykeypad-driver
LikeLike
The datasheet is good but how to programmme when different segment of led connect with different pin of the IC. At that moment the program which shows here can not run..
Pls tell how to resolve
LikeLike