Showing posts with label TM1638. Show all posts
Showing posts with label TM1638. Show all posts

Monday, January 25, 2021

Comparing two TM1638 modules

 Some year ago i also ordered another TM1638, so now i have 2 different types of TM1638 modules this blog post to compare the modules.

ModuleTM1638 LedQTF_TM1628
ConnectionPCB with Dupont connectorsPCB with dupont connectors
Posthttps://blog.jeronimus.net/2017/07/tm1638-8-bit-digital-led-module-1.html
https://blog.jeronimus.net/2021/01/qyf-tm1638-test.html
Picture
LCD display88
Led80
Dupont
Pin Arrangement
(top-down)
  • VCC
  • GND
  • STB
  • CLK
  • DIO
  • GND
  • DIO
  • CLK
  • STB
  • VCC
Buttons816
Buttons816
Buttons816

Both modules have 8 seven segment displays.
The big difference is that my first module has 8 leds and less (8) input keys, while my second module has 16 keys and no leds. As the 16 pins are arranged as 4*4 this module can be used as a Hex keypad. 
The Dupont pin arrangement on both PCBs is different.
Below schematic diagram of the modules as i did not put it in my previous posts. 



Diagrams and some other interesting info (in Italian) about these modules can be found at http://www.microcontroller.it/Tutorials/Elettronica/componenti/tm1638.htm

Sunday, January 24, 2021

QYF-TM1638 test

Tested my QYF TM1638 module with Arduino Uno

After some experimenting with my QYF-TM1628 board i got the example found at http://www.getmicros.net/arduino-qyf-tm1638-module-example.php
and arduino library at https://github.com/rjbatista/tm1638-library working.

First i tried without success another example found somewhere else on the internet. After further searching i found the example mentioned above. I had some doubt as the text in the wiring picture contained an error (two times GND at the Pinout text in the picture). I followed the wiring as displayed in the picture and the code, So my wiring was

  • Gnd – GND from Arduino
  • DIO – data pin, another ouput from your Arduino (Pin 8)
  • CLK – clock pin, an output from your Arduino (Pin 9)
  • STB – strobe pin, an output from your Arduino (Pin 10)
  • VCC – 5v from Arduino (5V)

The Dupont wire provided with the module was Female-Female, so i replaced it with female-male to connect it with an Arduino Uno. 


Example code:

#include <TM1638.h> #include <TM1638QYF.h>   TM1638QYF module(8,9,10); word mode;   unsigned long startTime;   void setup() {   startTime = millis();     module.setupDisplay(true, 7);   mode = 0; }   void update(TM1638QYF* module, word* mode) {   word buttons = module->getButtons();   unsigned long runningSecs = (millis() - startTime) / 1000;     // button pressed - change mode   if (buttons != 0) {     *mode = buttons >> 1;       if (*mode < 128) {       module->clearDisplay();       delay(100);     }   }     switch (*mode) {     case 0:       module->setDisplayToDecNumber(runningSecs, 1 << 6);       break;     case 1:       module->setDisplayToDecNumber(runningSecs, 1 << 5, false);       break;     case 2:       module->setDisplayToHexNumber(runningSecs, 1 << 4);       break;     case 4:       module->setDisplayToHexNumber(runningSecs, 1 << 3, false);       break;     case 8:       module->setDisplayToBinNumber(runningSecs, 1 << 2);       break;     case 16:       char s[9];       sprintf(s, "Secs %03d", runningSecs % 999);       module->setDisplayToString(s, 1 << 1);       break;     case 32:       if (runningSecs % 2 == 0) {         module->setDisplayToString("TM1638QY", 1);       } else {         module->setDisplayToString(String("LIBRARY "), 1);       }         break;     case 64:       module->setDisplayToError();       break;     case 128:       module->setDisplayToDecNumber(*mode, 0);       break;     case 256:       module->setDisplayToString("ABCDE", 1 << (runningSecs % 8));       break;     default:       module->setDisplayToBinNumber(buttons & 0xF, buttons >> 8);   } }

Thursday, January 21, 2021

2021 January Mailbag



 Some items in from my january 2021 mailbag from AliExpress
TM1638

QYF_TM1638

A PCB with 16 buttons and 8 seven segment displays and a driver that looks nice to use for I/O in projects e.g. with an Arduino.

10PCBs with 4 buttons

PCB with 4 Buttons

10 PCBs with 4 buttons each.
The PCBs and buttons are somewhat smaller than expected. (About 32mm*8 mm) However they are relative cheap and can be used easy in projects. Expect to use some with Dupont pins for use on a breadboard, some with wires and some direct soldered in projects. Also the next item is a reason that i did buy this cheap 4 buttons on a PCB.

433 MHz receiver / transmitter.

10 sets 433 MHz receivers and transmitters. Each set has 4 channels. I do not know if the signals interfere. It would be easy to connect one of the 4 button PCBs above with one of the 433 MHz transmitter. Where i ordered them antenna's where not included. However there are instructions how to make simple antennas for the receiver and transmitter.  I hope to find time to make an antenna set and test this item and post an update with more details on this blog.

UV Lamp

On AliExpress i also found this relative cheap 220 - 110 Volt UV Lamp. I ordered the 220Volt version without power plug and it came well packaged in foam. With a real UV lamp never radiate living tissue, your skin and take special care to protect your eyes.   I don't know if it really is an UV lamp and if it can be used for disinfection.   I have somewhere a UV detection card to test it. I decided to give it a try, perhaps it will be useful to radiate my postbag items. I did not test it yet.

Arduino CNC Shield

As i have on my long term wish list to experiment with a 3D printer / CNC machine or laser engraver i ordered this shield for an Arduino Uno. For the upcoming months i already have other plans, so this will become a long term project. However as i do not know how easy it will be in the future to get items from AliExpress i decided to already but this Arduino Uno Shield. 

 Arduino Mega and Enclosure

This two items (on one photo) where a little disappointing. It are two separate items bought from the same seller at AliExpress. On the right an Arduino Mega. On the left and middle a cheap enclodure to protect the Arduino Mega. When the enclosure came the top plate (in the middle of the photo) was not broken. This was due to my fault! I was surprised how easy it brake. I have mounted several similar enclosures for Arduino Uno's. This was the first one for Arduino Mega. The top plate from the enclosure (on the photo in the middle) dropped from table height on the floor and did brake.
Mounting of this cheap enclosure on the Chinese Arduino Mega clone was already a problem so unfortunate it was not a big loss. On this Arduino Mega the power and USB connectors are not on the exact right place so it did not fit in the holes of the enclosure. I think i will only mount the Arduino Mega on the base plate. I noticed the base plate has also holes for using it with an Arduino Uno what is a plus for this enclosure. For an Arduino Uno the holes fit exact so i expect the problem is the Arduino Mega. However i want to inform readers of this blog about the two minus points:
The top plate of the enclosure is fragile.
I think the power and USB connectors on this Arduino Mega Clone are not on the exact right position, so it does not fit in a 'standard enclosure'. 




Tuesday, July 11, 2017

TM1638 8 bit digital Led module (1)


On Aliexpress i found this Key Display "For AVR Arduino" "New" 8-Bit Digital LED Tube 8-Bit TM1638 Module. I did put some quotes" in the name as this module is not for Arduino only, it can be used also in projects with other microcontrollers e.g. the ESP8266.
TM1638 module - Front
For this module i payed 2017Q1 only € 1,32 . Relative cheap for a module that only needs 3 lines from your microcontroller and gives you
  • 8 keys
  • 8 LEDs common cathode
  • 8 a digital 7 segment displays
The magic is done using the TM1638 digital tube drive chip.
For the wiring connect VCC GND to a 5V supply and connect STB CLK DIO to the microcontroller IO ports. Scanning display and key scan don't need microcontroller intervention, only need to register to display data related to reading and writing or testing buttons, save MCU resources.
The only disadvantage i found is, when putting this module in an enclosure the female connections pins of this module are pointing to the front. Depending of the enclosure you need to remove, bend or put them on the back side of the module.

I tested it with an Arduino (clone).
Sketch 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);
}

Arduino Uno (clone) with TM1638 display (and key) module.


Sketch to test input keys
./*
 * Testing the TM1638 board
 Button test:
 Progam scans buttons. If 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

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

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

Back side
There exists also a library to easy program this module.