5082-74XX
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 | 1 |
6 | CATHODE 4 | 12 (přes odpor 220ohm) |
7 | G | 8 |
8 | D | 5 |
9 | F | 7 |
10 | CATHODE 2 | 10 (přes odpor 220ohm) |
11 | B | 3 |
12 | A | 2 |
Zdrojový kód pro Arduino
#include "SevSeg.h"
SevSeg sevseg;
byte numDigits = 4;
byte digitPins[] = {9, 10, 11, 12};
byte segmentPins[] = {2, 3, 4, 5, 6, 7, 8, A0};
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 int 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