56 lines
974 B
C++
56 lines
974 B
C++
const int PinBottom = 2;
|
|
const int PinTop = 5;
|
|
|
|
const int PinDigit3 = 3;
|
|
const int PinDigit2 = 4;
|
|
|
|
|
|
void setup()
|
|
{
|
|
pinMode(PinTop, OUTPUT);
|
|
pinMode(PinBottom, OUTPUT);
|
|
pinMode(PinDigit3, OUTPUT);
|
|
pinMode(PinDigit2, OUTPUT);
|
|
|
|
digitalWrite(PinTop, LOW);
|
|
digitalWrite(PinBottom, LOW);
|
|
}
|
|
|
|
int lastTime = 0;
|
|
bool top = true;
|
|
|
|
void loop()
|
|
{
|
|
int currentTime = millis();
|
|
if (currentTime - lastTime > 1000)
|
|
{
|
|
top = !top;
|
|
lastTime = currentTime;
|
|
}
|
|
|
|
// Digit 3 (right) - switch between top and bottom
|
|
digitalWrite(PinDigit3, HIGH);
|
|
|
|
if (top)
|
|
{
|
|
digitalWrite(PinTop, HIGH);
|
|
delay(1);
|
|
digitalWrite(PinTop, LOW);
|
|
}
|
|
else
|
|
{
|
|
digitalWrite(PinBottom, HIGH);
|
|
delay(1);
|
|
digitalWrite(PinBottom, LOW);
|
|
}
|
|
digitalWrite(PinDigit3, LOW);
|
|
|
|
|
|
// Digit 2 (middle) - always bottom
|
|
digitalWrite(PinDigit2, HIGH);
|
|
digitalWrite(PinBottom, HIGH);
|
|
delay(1);
|
|
digitalWrite(PinBottom, LOW);
|
|
digitalWrite(PinDigit2, LOW);
|
|
}
|