#include "SevSeg.h"
SevSeg sevseg;
byte symbol_code[3]={63,7,113};
byte segment_port[7]={2,3,4,5,6,7,8};
#define MAX_NUMBER_STRINGS 12
#define MAX_STRING_SIZE 8
char testStrings[MAX_NUMBER_STRINGS][MAX_STRING_SIZE];
#define PATTERN_CHANGE_TIME 1000
unsigned long timer = millis() - PATTERN_CHANGE_TIME;
byte testStringsPos = 0;
void setup() {
for(byte i=0;i<7;i++) pinMode(segment_port[i], OUTPUT);
byte numDigits = 4;
byte digitPins[] = {14,16,17,20};
byte segmentPins[] = {9,10,11,12,13,15,18,19};
bool resistorsOnSegments = false; // 'false' means resistors are on digit pins
byte hardwareConfig = COMMON_CATHODE; // See README.md for options
bool updateWithDelays = false; // Default. Recommended
bool leadingZeros = false; // Use 'true' if you'd like to keep the leading zeros
sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments, updateWithDelays, leadingZeros);
sevseg.setBrightness(90);
// Adds set of test strings with periods in various places
strcpy(testStrings[0], "A..BC.");
strcpy(testStrings[1], "....");
strcpy(testStrings[2], ". ");
strcpy(testStrings[3], " . ");
strcpy(testStrings[4], " . ");
strcpy(testStrings[5], " .");
strcpy(testStrings[6], ".ABC");
strcpy(testStrings[7], "A.BCD");
strcpy(testStrings[8], "A.B.CD");
strcpy(testStrings[9], "A.B.C.D");
strcpy(testStrings[10], "A.B.C.D.");
strcpy(testStrings[11], ". . . .");
}
void display(byte symbol)
{
for(byte i =0;i<7;i++)
{
boolean state = (symbol_code[symbol]>>i)&1;
digitalWrite(segment_port[i],state);
}
}
void loop() {
for(byte i=0;i<3;i++)
{
display(10);
display(i);
delay(1200);
}
if (millis() > (timer + PATTERN_CHANGE_TIME)) {
sevseg.setChars(testStrings[testStringsPos]);
testStringsPos++;
if (testStringsPos >= MAX_NUMBER_STRINGS) testStringsPos = 0;
timer = millis();
}
sevseg.refreshDisplay(); // Must run repeatedly
}