Home LED projects Arduino and a TM1638 module

Arduino and a TM1638 module

by shedboy71

When I was browsing various web sites to see what electronic components to buy one day I noticed some interesting little kits comprising of switches, LEDs and a couple of 4 digit seven segment displays saw I decided to purchase one, the first thing I noticed was at the heart of the module was a chip called a TM1638, never heard of it. A quick search dug up links to the datasheet (link supplied underneath in the links section) and an arduino library (in the code section). That makes life easier.

The module I bought had 5 connections.

VCC – 5v from Arduino
Gnd – GND from Arduino
STB – strobe pin, an output from your Arduino
CLK – clock pin, an output from your Arduino
DIO –  data pin, another ouput from your Arduino

Layout

arduino and TM1638 arduino and TM1638

Code

You can get a library to make development easier from https://code.google.com/p/tm1638-library/

In the example below we use a couple of functions built into the library, there are various others that are available. We will count to 100 and then display a message.

setDisplayToDecNumber – Decimal numbers will be displayed
setDisplayToString – Displays some text on the segments

 

 

[codesyntax lang=”cpp”]

#include <TM1638.h>
// define a module on data pin 8, clock pin 9 and strobe pin 10
TM1638 module(8, 9, 10);
unsigned long a=1;

void setup()
{
}

void loop()
{
for (a=1; a<=100; a++)
{
module.setDisplayToDecNumber(a,0,false);
delay(100);
}
module.setDisplayToString("Complete");
delay(1000);
}

[/codesyntax]

 

 

Links

TM1638 English datasheet

TM1638 F71A 8* Digital Tube + 8* Key + 8* Double Color LED Module

TM1638 LED keyboard scanning and display module

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More