We published an introductory guide with TM1637 7 segment LED display many months ago and later shown many advanced tutorials on this website. Snake animation is used in the proprietary led displays to indicate working, busy. Those are common on DVD players, satellite television receiver sets etc. A dash like —- like bright thing rotates throughout the border of the rectangle. Here are examples of Arduino TM1637 scrolling text, snake.
Arduino TM1637 Scrolling Text, Snake Examples
Basic thing is that a new library with more good examples with TM1637 discovered. I was trying to create the snake thing for the proprietary effect for a future project. Initially I found some Russian websites. Luckily later found near ready to use example. However, for my purpose the snake needs to be longer! Example is with 1 segment light. I need 11 segment long snake which will move like this :
1 2 3 4 5 6 7 8 9 | __ __ __ __ | | |__ __ __ | __ __ __ __ | | |__ __ __| __ __ __ __ | | |__ __ __| |
Example snake moves like this (exactly “negative film” of what I want) :
---
1 2 3 4 | |__ | | |
But the library has very useful things and functions including easy scrolling text creation. Go here :
1 | https://github.com/bremme/arduino-tm1637 |
and download the zip file, save on desktop. In case of Mac, it will get extracted, in case of Windows extract it. You’ll rename the directory as bramharmsen-arduino-tm1637
. Open the directory and open library.properties
file as plain text. Modify the first like shown below :
1 2 3 4 | name=bramharmsenSevenSegmentTM1637 version=1.0.0 author=Bram Harmsen <bramharmsen@gmail.com> maintainer=Bram Harmsen <bramharmsen@gmail.com> |
Save the file and zip the directory. You have bramharmsen-arduino-tm1637.zip
on desktop. Open Arduino IDE, go to Sketch > Include Library > Add .ZIP File. That thing will get installed. The location of library is Documents/Arduino/libraries/
in case of Mac. The reason to rename is that, there are other SevenSegmentTM1637 libraries with different examples.
Arduino TM1637 Snake Example
Connect TM1637’s VCC with Arduino’s 5V, GND to GND, CLK to Pin 4, DIO with Pin 5. This will give you snake :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include "SevenSegmentTM1637.h" #include "SevenSegmentExtended.h" #include "SevenSegmentFun.h" const byte PIN_CLK = 4; // define CLK pin const byte PIN_DIO = 5; // define DIO pin SevenSegmentFun display(PIN_CLK, PIN_DIO); void setup() { Serial.begin(9600); display.begin(); display.setBacklight(50); delay(1000); }; void loop() { byte repeats = 2; display.snake(repeats); } |
From Arduino IDE’s Example menu, you’ll find bramharmsen-arduino-tm1637
examples. There are really lot of examples. Inside the Documents/Arduino/libraries/
(in case of Mac) directory you’ll find the bramharmsen-arduino-tm1637
directory. There will be src
directory. Inside that directory there will be SevenSegmentFun.h
, SevenSegmentFun.cpp
etc files. You can edit them to customize the things.