Připojení k Arduinu
Pin 5082-7414 | Název pinu 5082-7414 | Pin Arduino |
---|
1 | CATHODE 1 | 9 (přes odpor 220ohm) |
2 | E | 6 |
3 | C | 4 |
4 | CATHODE 3 | 11 (přes odpor 220ohm) |
5 | DP | A2 |
6 | D | 5 |
7 | CATHODE 5 | A1 (přes odpor 220ohm) |
8 | G | 8 |
9 | CATHODE 4 | 12 (přes odpor 220ohm) |
10 | F | 7 |
11 | NC | – |
12 | B | 3 |
13 | CATHODE 2 | 10 (přes odpor 220ohm) |
14 | A | 2 |
Zdrojový kód pro Arduino
#include "SevSeg.h"
SevSeg sevseg;
byte numDigits = 5;
byte digitPins[] = {9, 10, 11, 12, A0};
byte segmentPins[] = {2, 3, 4, 5, 6, 7, 8, A1};
bool resistorsOnSegments = false;
byte hardwareConfig = COMMON_CATHODE;
bool updateWithDelays = false;
bool leadingZeros = true;
void setup() {
sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments, updateWithDelays, leadingZeros);
sevseg.setBrightness(90);
}
void loop() {
static unsigned long timer = millis();
static long deciSeconds = 0;
static byte deciPoint = 0;
if (millis() - timer >= 300) {
timer += 300;
deciSeconds++;
deciPoint++;
if (deciPoint == numDigits) {
deciPoint = 0;
}
if (deciSeconds == pow(10, numDigits)) {
deciSeconds = 0;
}
sevseg.setNumber(deciSeconds, deciPoint);
}
sevseg.refreshDisplay();
}
Demo video