Electronics

7 Segment Display LED 8-bit 7SEG Display Module TM1638 With 8 Buttons, 8 LED's

AED 25.20

1

Description

7Segment Display LED 8-bit 7SEG Display Module TM1638 With 8 Buttons, 8 LED's consist of 8 Bits 7Seg, 8 keys, 8 LEDs, a common cathode LED 7Seg. With the TM1638 Chip, you can drive it with only 3 pins from the Arduino or any other microcontroller, and you don't waste any computing power from the Arduino scanning for what button was pressed because It only needs to read the relevant register to send display data or test button so it saves MCU resources effectively.

The module has just 3 interface pins plus 2 pins for power (5VDC) and ground (0V). 

Specifications: 

  • Chipset: TM1638
  • Supply Voltage: 5VDC
  • Display: 8 x LEDs and 8 x 7 Segment Displays
  • Input: 8 x Push Button Switches
  • Control pins: Data, Clock, Strobe
  • Size: 75 x 48mm


To read the TM1638 datasheet you can CLICK HERE.

Following are the key features of the 28-pin TM1638 IC as found in its datasheet:

  • CMOS technology
  • 10 segments × 8 bits display
  • Keypad scanning (8 × 3 bits)
  • Brightness adjustment circuit (8-level adjustable duty ratio)
  • Serial interfaces (CLK, STB, DIO)
  • Oscillation mode: RC oscillation
  • Built-in power-on reset circuit
  • Package type: SOP28

 

Arduino Connections with the 7Segment Display LED 8-bit 7SEG Display Module TM1638 With 8 Buttons, 8 LEDs:


Arduino-Connections-with-the-7Segment-Display-LED-8bit-7SEG-Display-Module-TM1638-With-8Buttons-8LEDs


Arduino Code for the 7Segment Display LED 8-bit 7SEG Display Module TM1638 With 8 Buttons, 8 LED's to Test the Buttons:


/*

 * Testing the TM1638 board
 Button test:
 Progam scans buttons. If the button pressed the led over the button will be lit
Hardware connections: 
 Arduino              TM1638 based board
 3.3V   ------------------ VCC
 GND    ------------------ GND
 PIN #7 ------------------ STB
 PIN #8 ------------------ DIO
 PIN #9 ------------------ CLK


*/

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

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


Another Arduino Code for the 7Segment Display LED 8-bit 7SEG Display Module TM1638 With 8 Buttons, 8 LED's to Test the Display:

/*
 * Testing the TM1638 board
 Display test:
Programs dislights some leds and display
See code for details
Hardware connections: 
 Arduino              TM1638 based board
 3.3V   ------------------ VCC
 GND    ------------------ GND
 PIN #7 ------------------ STB
 PIN #8 ------------------ DIO
 PIN #9 ------------------ CLK

 Source
 https://blog.3d-logic.com/2015/01/10/using-a-tm1638-based-board-with-arduino/
 8 july 2017  JanJeronimus
*/

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

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