controlle TM1640 with arduino using shiftout function

HI guys, I hope you doing well

(sorry for my bad English, but i will do my best)

I have TM1640 LED driver here is the
datasheet ==>(https://cdn.solarbotics.com/products/datasheets/tm1640.pdf)

-TM1640 has got library on gitHub and it working fine,but i wand to run it with simple code using shiftout function (I worked before now with TM1639 usnig shiftout function it working well, it use 3 pins for communication (DIN, SCLK,STB), but TM1640 only use (DIN, SCLK) for communication )

I try to dig in to the TM1640 library, but i failed since it uses other libraries inside it.

  • According to datasheet pin 7 and 8 used for communication (DIN, SCLK)

  • by reading the instruction of datasheet I wrote this code,unfortunately it is not working

int clock = 8;
int data = 7;
 
void setup()
{
  pinMode(clock, OUTPUT);
  pinMode(data, OUTPUT);
 
  


digitalWrite(clock, HIGH);
digitalWrite(data, HIGH);
digitalWrite(data, LOW);

  shiftOut(data, clock, LSBFIRST, 0x8F);

digitalWrite(clock, LOW);
digitalWrite(data, LOW);
digitalWrite(clock, HIGH);
 digitalWrite(data, HIGH);
  
}
void loop()
{


digitalWrite(clock, HIGH);
digitalWrite(data, HIGH);
digitalWrite(data, LOW);

  shiftOut(data, clock, LSBFIRST, 0x44);

digitalWrite(clock, LOW);
digitalWrite(data, LOW);
digitalWrite(clock, HIGH);
 digitalWrite(data, HIGH);

  
digitalWrite(clock, HIGH);
digitalWrite(data, HIGH);
delayMicroseconds(50);
digitalWrite(data, LOW);

shiftOut(data, clock, LSBFIRST, 0xc1 ); // 1st digit
shiftOut(data, clock, LSBFIRST,0b10111111 );


digitalWrite(clock, LOW);
digitalWrite(data, LOW);
digitalWrite(clock, HIGH);
 digitalWrite(data, HIGH);
}

any one can tell where is the problem ?

thank you

by reading the instruction of datasheet I wrote this code,unfortunately it is not working

Read it again, your code has absolutely nothing to do with what is needed. It is not even close.

For a start it is pin 6 and 7 on the chip that controls the clock and data, nothing to do with pin 6 and 7 of the Arduino.

You should let the shift out do all the work, no need to put these lines up and down separate and then use shift out.

I don’t understand why you can not use the library you have found?

We need to see how you have wired things up. Please post a schematic.

thanks for answering, firstly according to the datasheet of TM1640 pin (7=DIN) and (8=SCLK) also as in attached(fig.1), I know there is not thing related to arduino side, it is just connecting similar pin number they can be other two pins at arduino side (e.g 3 and 4)

my connection as below:-

arduino TM1640


7 ==> 7
8 ==> 8
5v ==> Vdd
Gnd ==> Vss

secondly why I don't want to use the TM1640 lib?

for following reasons

1-To understand how does the connection established between the two ICs (in software side) since when I use lib. is just type the function and it worked, what happened to make it work I don't know

2- The TM1640 which I have is directly connected to 16 digit 7 segment display in such a connection that doesn't Match with the library parameters ( as e.g when I type "123") it light randomly segment, it looks randomly, but when you concentrate the number of segments which needed to light up for "123" is same number of random segments .
so I need to know how does it work to make is suitable for my situation

finaly, I solved it, the problem was with shiftout function it doesn't work here it need to be modified.
and now it working

my aim is
I have a Chinese MUC which control TM1640(using DIO and SCLK ) to display numbers,
I want to connect these two wire to arduino to read the numbers which will display,
after figuring out how TM1640 work now I'm able to translate the binary data which comes from MUC
and it can be catch using SPI on arduino side

the problem now there is shifting when the data readied at arduino side (e.g the 0b00000001 which equal to 1, the arduino SPI reading it 0b00000010 = 2)
do you have any ideas,please
thank you.

fig1.jpg

which equal to 1, the arduino SPI reading it

As you haven't mentioned SPI before I am not sure what you mean.

You need to post your "fixed" code along with a schematic and try and explain what it does and what you would like it to do a bit better than you have.