Here's my code ^
It complies but the '8 Seven Segment LED Display with Keys' doesn't.
Nothing appears.
You need to post your code using code tags and post a wiring diagram.
Hi,
Welcome to the forum.
Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
What model Arduino are you using?
Thanks.. Tom... ![]()
Your code uses a TM1638.h file, presumably from a library named "TM1638". Your sketch does not say where to find the library and Library Manager only has "TM1638lite" and "TM1638plus", neither of which is "TM1638".
#include <TM1638.h>
const int strobe = 3;
const int clk = 4;
const int data = 5;
int dots = 0x0; // display all decimal points, value in hexadecimal
int leds = 0xFF; // mask to display LEDS
byte keys; // key value
double number; // number to display
// define a module
TM1638 module(data, clk, strobe);
void setup()
{
Serial.begin(9600);
module.clearDisplay(); // clear the display
number = 12345678; // decimal number
}
void loop()
{
// display a number
switch (keys)
{
case 0:
module.setDisplayToDecNumber(number, dots);
break;
case 1:
module.setDisplayToHexNumber(number, dots);
break;
case 2:
module.setDisplayToBinNumber(number, dots);
break;
case 4:
module.clearDisplay(); // clear the display
break;
case 8:
module.setDisplayToString("testing ");
break;
case 16:
break;
case 32:
break;
case 64:
break;
case 128:
break;
default:
break;
}
// get a key press
getKeyPressed();
//
}
void getKeyPressed()
{
keys = module.getButtons();
Serial.println(keys);
// light the LED
module.setLEDs(keys & leds);
}
I located a library that seems to work with your sketch: GitHub - rjbatista/tm1638-library: Automatically exported from code.google.com/p/tm1638-library
It has not been updated in five years and generates a lot of warnings so it may need to be updated to work with the current Arduino IDE.
Do the examples that came with the library work correctly? Are you sure your display module is wired correctly?
/Users/john/Documents/Arduino/libraries/tm1638-library-master/InvertedTM1638.cpp: In member function 'virtual void InvertedTM1638::sendChar(byte, byte, boolean)':
/Users/john/Documents/Arduino/libraries/tm1638-library-master/InvertedTM1638.cpp:56:33: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses]
TM1638::sendChar(7 - pos, data & 0xC0 | (data & 0x07) << 3 | (data & 0x38) >> 3, dot);
~~~~~^~~~~~
/Users/john/Documents/Arduino/libraries/tm1638-library-master/TM16XX.cpp: In member function 'virtual void TM16XX::setDisplay(const byte*, unsigned int)':
/Users/john/Documents/Arduino/libraries/tm1638-library-master/TM16XX.cpp:86:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < size; i++) {
~~^~~~~~
In file included from /Users/john/Documents/Arduino/libraries/tm1638-library-master/TM1638QYF.cpp:25:0:
/Users/john/Documents/Arduino/libraries/tm1638-library-master/TM1638QYF.h: In member function 'virtual void TM1638QYF::setDisplayDigit(byte, byte, boolean, const byte*)':
/Users/john/Documents/Arduino/libraries/tm1638-library-master/TM1638QYF.h:68:39: warning: unused parameter 'digit' [-Wunused-parameter]
virtual void setDisplayDigit(byte digit, byte pos, boolean dot, const byte numberFont[] = NUMBER_FONT) { setDisplayToError(); };
^~~~~
/Users/john/Documents/Arduino/libraries/tm1638-library-master/TM1638QYF.h:68:51: warning: unused parameter 'pos' [-Wunused-parameter]
virtual void setDisplayDigit(byte digit, byte pos, boolean dot, const byte numberFont[] = NUMBER_FONT) { setDisplayToError(); };
^~~
/Users/john/Documents/Arduino/libraries/tm1638-library-master/TM1638QYF.h:68:64: warning: unused parameter 'dot' [-Wunused-parameter]
virtual void setDisplayDigit(byte digit, byte pos, boolean dot, const byte numberFont[] = NUMBER_FONT) { setDisplayToError(); };
^~~
/Users/john/Documents/Arduino/libraries/tm1638-library-master/TM1638QYF.h:68:95: warning: unused parameter 'numberFont' [-Wunused-parameter]
virtual void setDisplayDigit(byte digit, byte pos, boolean dot, const byte numberFont[] = NUMBER_FONT) { setDisplayToError(); };
^~~~~~~~~~~
In file included from /Users/john/Documents/Arduino/libraries/tm1638-library-master/TM1638QYF.cpp:25:0:
/Users/john/Documents/Arduino/libraries/tm1638-library-master/TM1638QYF.h: In member function 'virtual void TM1638QYF::clearDisplayDigit(byte, boolean)':
/Users/john/Documents/Arduino/libraries/tm1638-library-master/TM1638QYF.h:70:41: warning: unused parameter 'pos' [-Wunused-parameter]
virtual void clearDisplayDigit(byte pos, boolean dot) { setDisplayToError(); };
^~~
/Users/john/Documents/Arduino/libraries/tm1638-library-master/TM1638QYF.h:70:54: warning: unused parameter 'dot' [-Wunused-parameter]
virtual void clearDisplayDigit(byte pos, boolean dot) { setDisplayToError(); };
^~~
/Users/john/Documents/Arduino/libraries/tm1638-library-master/TM1638QYF.h: In member function 'virtual void TM1638QYF::sendChar(byte, byte, boolean)':
/Users/john/Documents/Arduino/libraries/tm1638-library-master/TM1638QYF.h:72:29: warning: unused parameter 'pos' [-Wunused-parameter]
virtual void sendChar(byte pos, byte data, boolean dot) { setDisplayToError(); }
^~~
/Users/john/Documents/Arduino/libraries/tm1638-library-master/TM1638QYF.h:72:39: warning: unused parameter 'data' [-Wunused-parameter]
virtual void sendChar(byte pos, byte data, boolean dot) { setDisplayToError(); }
^~~~
/Users/john/Documents/Arduino/libraries/tm1638-library-master/TM1638QYF.h:72:53: warning: unused parameter 'dot' [-Wunused-parameter]
virtual void sendChar(byte pos, byte data, boolean dot) { setDisplayToError(); }
^~~
/Users/john/Documents/Arduino/libraries/tm1638-library-master/TM1638QYF.cpp: In member function 'virtual void TM1638QYF::setDisplay(const byte*, unsigned int)':
/Users/john/Documents/Arduino/libraries/tm1638-library-master/TM1638QYF.cpp:39:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = 0; j < length; j++) {
~~^~~~~~~~
/Users/john/Documents/Arduino/libraries/tm1638-library-master/TM1638QYF.cpp: In member function 'virtual void TM1638QYF::setDisplayToString(const char*, word, byte, const byte*)':
/Users/john/Documents/Arduino/libraries/tm1638-library-master/TM1638QYF.cpp:52:84: warning: unused parameter 'ignored' [-Wunused-parameter]
void TM1638QYF::setDisplayToString(const char* string, const word dots, const byte ignored, const byte font[])
^~~~~~~
/Users/john/Documents/Arduino/libraries/tm1638-library-master/TM1638QYF.cpp: In member function 'virtual void TM1638QYF::setDisplayToString(String, word, byte, const byte*)':
/Users/john/Documents/Arduino/libraries/tm1638-library-master/TM1638QYF.cpp:71:79: warning: unused parameter 'ignored' [-Wunused-parameter]
void TM1638QYF::setDisplayToString(String string, const word dots, const byte ignored, const byte font[])
^~~~~~~
/Users/john/Documents/Arduino/libraries/tm1638-library-master/TM1638QYF.cpp: In member function 'void TM1638QYF::setDisplayToHexNumber(long unsigned int, byte, boolean, const byte*)':
/Users/john/Documents/Arduino/libraries/tm1638-library-master/TM1638QYF.cpp:107:69: warning: format '%X' expects argument of type 'unsigned int', but argument 4 has type 'long unsigned int' [-Wformat=]
snprintf(values, displays + 1, leadingZeros ? "%08X" : "%X", number); // ignores display size
^
/Users/john/Documents/Arduino/libraries/tm1638-library-master/TM1638QYF.cpp:107:69: warning: format '%X' expects argument of type 'unsigned int', but argument 4 has type 'long unsigned int' [-Wformat=]
/Users/john/Documents/Arduino/libraries/tm1638-library-master/TM1638QYF.cpp: In member function 'void TM1638QYF::setDisplayToSignedDecNumber(long int, byte, boolean, const byte*)':
/Users/john/Documents/Arduino/libraries/tm1638-library-master/TM1638QYF.cpp:129:69: warning: format '%d' expects argument of type 'int', but argument 4 has type 'long int' [-Wformat=]
snprintf(values, displays + 1, leadingZeros ? "%08d" : "%d", number); // ignores display size
^
/Users/john/Documents/Arduino/libraries/tm1638-library-master/TM1638QYF.cpp:129:69: warning: format '%d' expects argument of type 'int', but argument 4 has type 'long int' [-Wformat=]
Sketch uses 6550 bytes (22%) of program storage space. Maximum is 28672 bytes.
Global variables use 354 bytes (13%) of dynamic memory, leaving 2206 bytes for local variables. Maximum is 2560 bytes.