NerfStatTrak/NerfStatTrek.ino

41 lines
735 B
Arduino
Raw Normal View History

#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);
}