Skip to content

Instantly share code, notes, and snippets.

@7effrey89
Created May 10, 2018 20:12
Show Gist options
  • Select an option

  • Save 7effrey89/1efc777704219ec455a42b0803fdee46 to your computer and use it in GitHub Desktop.

Select an option

Save 7effrey89/1efc777704219ec455a42b0803fdee46 to your computer and use it in GitHub Desktop.
TM1637 on NodeMCU
/*
Basic usage example
Demonstrated some of the basic functionality of the library. Initialize the display, set the backlight brightness, print some text, count from 0 to 100 and print on display and blink some text.
Note: make sure to set your serial monitor to line end: NEW LINE!
The circuit:
* connect TM1637 pin CLK to NodeMCU pin D4
* connect TM1637 pin DIO to NodeMCU pin D5
* connect TM1637 pin Vcc to ext 5V
* connect TM1637 pin GND to ext GND
https://github.com/bremme/arduino-tm1637
*/
// include the SevenSegmentTM1637 library
#include "SevenSegmentTM1637.h"
/* initialize global TM1637 Display object
* The constructor takes two arguments, the number of the clock pin and the digital output pin:
* SevenSegmentTM1637(byte pinCLK, byte pinDIO);
*/
const byte PIN_CLK = D6; // define CLK pin (any digital pin)
const byte PIN_DIO = D5; // define DIO pin (any digital pin)
SevenSegmentTM1637 display(PIN_CLK, PIN_DIO);
// run setup code
void setup() {
Serial.begin(9600); // initializes the Serial connection @ 9600 baud
display.begin(); // initializes the display
display.setBacklight(100); // set the brightness to 100 %
display.print("INIT"); // display INIT on the display
delay(1000); // wait 1000 ms
};
// run loop (forever)
void loop() {
display.print("LOOP"); // display LOOP on the display
delay(1000); // wait 1000 ms
display.print("COUNTING SOME DIGITS");// print COUNTING SOME DIGITS
display.clear(); // clear the display
for (uint8_t i=0; i < 100; i++) { // loop from 0 to 100
display.print(i); // display loop counter
delay(100); // wait 100 ms
};
display.clear(); // clear the display
display.print("SUCC"); // print SUCC for success
display.blink(); // blink SUCC
delay(1000); // wait 1000 ms
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment