gavinlyonsrepo / TM1638plus

An Arduino library to drive TM1638 seven segment modules.
https://gavinlyonsrepo.github.io/
GNU General Public License v3.0
79 stars 25 forks source link

Add example of two Type 1 modules #10

Closed maxholgasson closed 4 years ago

maxholgasson commented 4 years ago

Hi, could you add an example how to drive two type1 modules? As I understood CLK and DIO can be shared for both modules and one module need a seperate line for STB and the second modules a own line as well.

gavinlyonsrepo commented 4 years ago

Hi

I have never done this before and I do not have two model 1's. I just wired model 1 and 3 together(they are same besides LED's from SW point of view.) Yes as you say , you just connect a unique STB line to each individual module and the CLK and DIO can be shared. Here is example ino file I used.

`#include

define STROBE_TM1 4

define CLOCK_TM 6

define DIO_TM 7

define STROBE_TM2 8

bool high_freq = false;

//Constructor object (GPIO STB , GPIO CLOCK , GPIO DIO, use high freq MCU) TM1638plus tm1(STROBE_TM1, CLOCK_TM , DIO_TM, high_freq); TM1638plus tm2(STROBE_TM2, CLOCK_TM , DIO_TM, high_freq);

void setup() { tm1.displayBegin(); tm2.displayBegin(); }

void loop() { tm1.displayText("abcdfegh"); tm1.setLED(0x01, 0x02); tm2.displayText("12345678"); tm2.setLED(0x01,0x01); delay(5000); }`

link

gavinlyonsrepo commented 4 years ago

Here is an example testing the buttons

`#include

//pick on any I/O you want.

define STROBE_TM1 4

define CLOCK_TM 6

define DIO_TM 7

define STROBE_TM2 8

bool high_freq = false;

//Constructor object (GPIO STB , GPIO CLOCK , GPIO DIO, use high freq MCU) TM1638plus tm1(STROBE_TM1, CLOCK_TM , DIO_TM, high_freq); TM1638plus tm2(STROBE_TM2, CLOCK_TM , DIO_TM, high_freq);

void setup() { tm1.displayBegin(); tm2.displayBegin(); Serial.begin(9600); delay(1000); }

void loop() { while (1) // Loop here forever { uint8_t buttons1 = tm1.readButtons(); uint8_t buttons2 = tm2.readButtons(); tm1.displayIntNum(buttons1, true); tm2.displayIntNum(buttons2, true); delay(250); } }`

gavinlyonsrepo commented 4 years ago

No need for another example file as its quite simple. Added a note to the readme pointing to this issue and the code.