🔍

7 segment display with Arduino


#include <Arduino.h>

#include <TM1637Display.h>

// https://www.makerguides.com/tm1637-arduino-tutorial/

// Module connection pins (Digital Pins)
#define CLK 2
#define DIO 3

 /*
const uint8_t SEG_DONE[] = {
	SEG_B | SEG_C | SEG_D | SEG_E | SEG_G,           // d
	SEG_A | SEG_B | SEG_C | SEG_D | SEG_E | SEG_F,   // O
	SEG_C | SEG_E | SEG_G,                           // n
	SEG_A | SEG_D | SEG_E | SEG_F | SEG_G            // E
	};
*/
TM1637Display display(CLK, DIO);
 

void setup() {
  // put your setup code here, to run once:

  display.setBrightness(7);
 
}

void loop() {
  // put your main code here, to run repeatedly:

   uint8_t data[] = { 0xff, 0xff, 0xff, 0xff };
  uint8_t blank[] = { 0x00, 0x00, 0x00, 0x00 };
  
   data[0] = uint8_t(random(256));
   data[1] = uint8_t(random(256));
   data[2] = uint8_t(random(256));
   data[3] = uint8_t(random(256));


  // All segments on
  display.setSegments(data);

  delay(20); 
  return;
  
  delay(500);
  display.showNumberDec(1234, false); // Expect: ___0
  delay(500);
}