NerfStatTrak/NerfStatTrek.ino
Mark van Renswoude 4c16260e55 Fixed data corruption issue due to incorrect PROGMEM usage
Added switchable shift register order
Added potentiometer-controlled delay for demonstration purposes
2016-11-27 23:14:17 +01:00

41 lines
735 B
C++

#include "SegmentDisplay.h"
SegmentDisplay* display;
void setup()
{
pinMode(A3, INPUT);
display = new SegmentDisplay();
//display->setClockSpeed(4000000UL);
display->setClockPin(12);
display->setDataPin(11);
display->setLatchPin(10);
display->setDigits(6);
display->begin();
}
unsigned long currentTime;
unsigned long lastCounterTime = 0;
uint32_t counter = 0;
uint32_t delayValue;
void loop()
{
currentTime = millis();
if (currentTime - lastCounterTime > 100UL)
{
counter++;
if (counter > 999999)
counter = 0;
lastCounterTime = currentTime;
delayValue = ((uint32_t)analogRead(A3) * 100);
display->setDigitDelayMicroseconds(delayValue);
}
display->writeNumber(counter);
}