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 i = 0;

    /* setup */
    TM1637_init();

    /* loop */
    while (1) {
        TM1637_display_digit(TM1637_SET_ADR_00H, i % 0x10);
        TM1637_display_digit(TM1637_SET_ADR_01H, (i + 1) % 0x10);
        TM1637_display_digit(TM1637_SET_ADR_02H, (i + 2) % 0x10);
        TM1637_display_digit(TM1637_SET_ADR_03H, (i + 3) % 0x10);
        TM1637_display_colon(true);
        _delay_ms(200);
        TM1637_display_colon(false);
        _delay_ms(200);
        i++;
    }
}

References

2 thoughts on “ATtiny13 – TM1637 Library

  1. 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