Skip to content

Instantly share code, notes, and snippets.

@ha1t
Created August 29, 2015 03:30
Show Gist options
  • Save ha1t/199816c4583853b6031c to your computer and use it in GitHub Desktop.
Save ha1t/199816c4583853b6031c to your computer and use it in GitHub Desktop.
#include "SevSeg.h"
SevSeg sevseg; //Instantiate a seven segment controller object
void setup() {
byte numDigits = 4;
byte digitPins[] = {3, 2, 1, 0};
byte segmentPins[] = {11, 10 ,9 ,8, 7, 6, 5, 4};
//sevseg.begin(COMMON_CATHODE, numDigits, digitPins, segmentPins);
sevseg.begin(COMMON_ANODE, numDigits, digitPins, segmentPins);
sevseg.setBrightness(70);
sevseg.setNumber(1234, 0);
}
void loop() {
static unsigned long timer = millis();
static int deciSeconds = 0;
if (millis() >= timer) {
deciSeconds++; // 100 milliSeconds is equal to 1 deciSecond
timer += 100;
if (deciSeconds == 10000) { // Reset to 0 after counting for 1000 seconds.
deciSeconds=0;
}
sevseg.setNumber(deciSeconds, 1);
}
sevseg.refreshDisplay(); // Must run repeatedly
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment