ATtiny13 – TM1637 Library

This article is about tinyAVR (ATtiny13, ATtiny25, ATtiny45, ATtiny85) library for 7-segment display modules based on TM1637 chip. These TM1637 modules provide two signal connections (CLK and DIO) and two power connections (VCC and GND). Signal pins can be connected to any pair of digital pins of the AVR chip. Signal pins configuration is defined at the top of library header file, where it can be modifed. Complete TM1637 library code is on GitHub, here.

Key Features

This lightweight library has the following features:

  • display digits
  • display raw segments
  • display colon
  • brightness control
  • display on/off
  • software I2C

Example Code

This sample code demonstrates basic usage of the library

#include <stdint.h>
#include <avr/io.h>
#include <util/delay.h>
#include "tm1637.h"

int
main(void)
{
	uint8_t n, k = 0;

	/* setup */
	TM1637_init(1/*enable*/, 5/*brightness*/);

	/* loop */
	while (1) {
		for (n = 0; n < TM1637_POSITION_MAX; ++n) {
			TM1637_display_digit(n, (k + n) % 0x10);
		}
		TM1637_display_colon(1);
		_delay_ms(200);
		TM1637_display_colon(0);
		_delay_ms(200);
		k++;
	}
}

References

10 thoughts on “ATtiny13 – TM1637 Library

  1. Dont know what im doing wrong but both first and second attiny tm1637 libraries and test codes dosnt work for me. Dont know why. There are many errors displayed. What is funny if i left it as include tm1637.h it throws over 10 errors, if i change it to tm1637.c i can make it build but it dosnt work. Dont understand why.

  2. Hello Podkalicki,
    I’m beginner to this world and I truly don’t understand what does the code “0b01110110” means, Bing says it is equivalent to 10.
    Can you please tell me to which code system the code belongs to.
    THANK YOU

    • It’s a binary (BIN) form of expressing numbers. Normally, we use the decimal (DEC) form. Computers usually use the binary or hexadecimal (HEX) form.

  3. Thank You for the libary. It works but I have Problems with Digit2 and its colon. Sometimes colon is on but should be off. Or Digt2 shows wrong segments. Are there known issues?

    • You’re first reporting it. Could you create an issue on Github? I’ll try to reproduce it.

  4. Hello Podkalicki,
    Thank you for this example. How I can use this library to connect tm1637 to a PIC16F88?
    Thank you for your help

    • You’re welcome! I have no idea how to port it to PIC. This library has been designed for tinyAVR family.

Leave a Comment