zondag 24 januari 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);   } }

Geen opmerkingen: