Four-digit 7-segment display with Arduino
FunduinoPublished on
Vier Ziffern per Multiplexing ansteuern – mit der SevSeg-Bibliothek
You need this
5461AS 7-segment display - 4-digit, red, common cathode
1,33 € *Item no. F23106605About the product — 5461AS 7-segment display - 4-digit, red, common cathode
Funduino UNO R3 Microcontroller - ATmega328P, 16 MHz, for Arduino
11,12 € *Item no. F23107480About the product — Funduino UNO R3 Microcontroller - ATmega328P, 16 MHz, for Arduino
830-point Breadboard - solderless breadboard for Arduino
2,90 € *Item no. FUN-1010553About the product — 830-point Breadboard - solderless breadboard for Arduino
Breadboard Cables Male-to-Male - 40 Pieces, 20 cm
1,74 € *Item no. FUN-1010558About the product — Breadboard Cables Male-to-Male - 40 Pieces, 20 cm
Resistor Assortment 100 Pieces - 5 Values 100 Ω to 10 kΩ, 0.5 W
1,72 € *Item no. F23107216About the product — Resistor Assortment 100 Pieces - 5 Values 100 Ω to 10 kΩ, 0.5 W
All 5 parts together 18,81 € *Ready to ship immediately · Delivery time: 1-3 business days
* All prices include statutory VAT, plus shipping costs.
The circuit diagram
1 / 2
Include the library
The program code
Display a number
#include "SevSeg.h" // Die vorher hinzugefügte Bibliothek laden
SevSeg sevseg; // Ein Sieben-Segment-Objekt initialisieren
void setup()
{
byte numDigits = 4; // Anzahl der Ziffern
byte digitPins[] = {2, 3, 4, 5}; // Pins zu den Ziffern
byte segmentPins[] = {6, 7, 8, 9, 10, 11, 12, 13}; // Pins zu den Segmenten
// Hier gibst du an, ob dein Display COMMON_CATHODE oder COMMON_ANODE ist.
// Es funktioniert nur mit der richtigen Angabe – sonst leuchten alle Segmente gleichzeitig.
sevseg.begin(COMMON_CATHODE, numDigits, digitPins, segmentPins);
}
void loop()
{
// Hier trägst du die gewünschte Zahl ein, im Beispiel 1234.
// Die Zahl dahinter steht für den Punkt hinter einer Ziffer: 3 ist der Punkt
// neben der ersten Ziffer, 0 der ganz rechts. Willst du keinen Punkt, gib z. B. 4 an.
sevseg.setNumber(1234, 3);
// Diese Zeile lässt die Zahl auf dem Display erscheinen.
sevseg.refreshDisplay();
// Helligkeit von 0 bis 100, 100 ist am hellsten. 0 bedeutet nicht völlig dunkel.
sevseg.setBrightness(90);
}Rate the instructions