Categories

QYF-TM1638 and Arduino module

This was a module based on the TM1638 IC that I purchased.

TM1638

TM1638

The imprtant connections are as follows

data pin 3
clock pin 2
strobe pin 5

I decided to create an example that would display the button pressed on the display, you will need the library below

The library is https://github.com/Leonardoventurin/tm1638-library

Code

#include <TM1638.h>
#include <TM1638QYF.h>
 
TM1638QYF module(3, 2, 5);
word mode;
 
 
void setup() 
{
  module.setupDisplay(true, 7);
  mode = 0;
}
 
void update(TM1638QYF* module, word* mode) {
  word buttons = module->getButtons();
 
  // button pressed - change mode
  if (buttons != 0) {
    *mode = buttons >> 1;
 
    if (*mode < 128) {
      module->clearDisplay();
      delay(100);
    }
  }
 
  switch (*mode) {
    case 0:
      module->setDisplayToString("press 1");
      break;
    case 1:
      module->setDisplayToString("press 2");
      break;
    case 2:
      module->setDisplayToString("press 3");
      break;
    case 4:
      module->setDisplayToString("press 4");
      break;
    case 8:
      module->setDisplayToString("press 5");
      break;
    case 16:
      module->setDisplayToString("press 6");
      break;
    case 32:
      module->setDisplayToString("press 7");
      break;
    case 64:
      module->setDisplayToString("press 8");
      break;
    case 128:
      module->setDisplayToString("press 9");
      break;
    case 256:
      module->setDisplayToString("press 10");
      break;
    case 512:
      module->setDisplayToString("press 11");
      break;
    case 1024:
      module->setDisplayToString("press 12");
      break;
    case 2048:
      module->setDisplayToString("press 13");
      break;
    case 4096:
      module->setDisplayToString("press 14");
      break;
    case 8192:
      module->setDisplayToString("press 15");
      break;
    case 16384:
      module->setDisplayToString("press 16");
      break;
    default:
      module->setDisplayToString("?????");
      break;
  }
}
 
void loop() 
{
  update(&module, &mode);
}

 

Link
3 line 8 led keyboard display module mcu module tm1638 free shipping

Share

Arduino and Tm1638 button example

This code snippet will get the button value and display the value on the 7 Segment LED and the LEDs

TM1638 Chip Key Display Module

TM1638 Chip Key Display Module

Code


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

byte buttons;
void setup()
{
}

void loop()
{
//get the button
//S1 = 1, S2 = 2, S3 = 4, S4 = 8
//S5 = 16, S6 = 32, S7 = 64, S8 = 128
buttons=module.getButtons();
module.setDisplayToDecNumber(buttons,0,false);
module.setLEDs(buttons);
}

Share

Arduino and a TM1638 module

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


#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);
}

Links

TM1638 English datasheet

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

TM1638 LED keyboard scanning and display module

Share