Mark van Renswoude
4c16260e55
Added switchable shift register order Added potentiometer-controlled delay for demonstration purposes
41 lines
735 B
C++
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);
|
|
}
|