2016-09-30 21:14:29 +00:00
|
|
|
#include "SegmentDisplay.h"
|
2016-09-24 12:12:19 +00:00
|
|
|
|
2016-09-30 21:14:29 +00:00
|
|
|
SegmentDisplay* display;
|
2016-09-24 12:12:19 +00:00
|
|
|
|
2016-09-26 21:14:03 +00:00
|
|
|
void setup()
|
2016-09-24 12:12:19 +00:00
|
|
|
{
|
2016-11-27 22:14:17 +00:00
|
|
|
pinMode(A3, INPUT);
|
|
|
|
|
2016-09-30 21:14:29 +00:00
|
|
|
display = new SegmentDisplay();
|
|
|
|
//display->setClockSpeed(4000000UL);
|
2016-11-27 22:14:17 +00:00
|
|
|
display->setClockPin(12);
|
|
|
|
display->setDataPin(11);
|
|
|
|
display->setLatchPin(10);
|
|
|
|
display->setDigits(6);
|
2016-09-30 21:14:29 +00:00
|
|
|
display->begin();
|
2016-09-24 12:12:19 +00:00
|
|
|
}
|
|
|
|
|
2016-11-27 22:14:17 +00:00
|
|
|
unsigned long currentTime;
|
2016-09-30 21:14:29 +00:00
|
|
|
unsigned long lastCounterTime = 0;
|
|
|
|
uint32_t counter = 0;
|
2016-11-27 22:14:17 +00:00
|
|
|
uint32_t delayValue;
|
2016-09-24 12:12:19 +00:00
|
|
|
|
2016-09-26 21:14:03 +00:00
|
|
|
void loop()
|
2016-09-24 12:12:19 +00:00
|
|
|
{
|
2016-11-27 22:14:17 +00:00
|
|
|
currentTime = millis();
|
2016-09-24 12:12:19 +00:00
|
|
|
|
2016-11-27 22:14:17 +00:00
|
|
|
if (currentTime - lastCounterTime > 100UL)
|
2016-09-24 12:12:19 +00:00
|
|
|
{
|
2016-09-30 21:14:29 +00:00
|
|
|
counter++;
|
2016-11-27 22:14:17 +00:00
|
|
|
if (counter > 999999)
|
2016-09-30 21:14:29 +00:00
|
|
|
counter = 0;
|
2016-09-24 12:12:19 +00:00
|
|
|
|
2016-09-30 21:14:29 +00:00
|
|
|
lastCounterTime = currentTime;
|
2016-11-27 22:14:17 +00:00
|
|
|
|
|
|
|
delayValue = ((uint32_t)analogRead(A3) * 100);
|
|
|
|
display->setDigitDelayMicroseconds(delayValue);
|
2016-09-30 21:14:29 +00:00
|
|
|
}
|
2016-09-24 12:12:19 +00:00
|
|
|
|
2016-09-30 21:14:29 +00:00
|
|
|
display->writeNumber(counter);
|
2016-09-24 12:12:19 +00:00
|
|
|
}
|