Arduino Lektion 62: 7 Segmentanzeige
Die 7 Segmentanzeige, gibt es bequem als Modul oder einzeln als Bauteil.
7 Segmentanzeige am MakerUNO
Möchte man die 7 Segmentanzeige einzeln, als Bauteil am Arduino betreiben so benötigt man
- 9 Kabel
- 2x 220 Ohm Widerstände
und natürlich einen Mikrocontroller, ich verwende den MakerUNO welcher baugleich mit dem Arduino UNO ist.
Bezug
Die 7 Segmentanzeige kann für ca. 1,8 € bei ebay.de bezogen werden. Es gibt die Anzeigen in der Farbe, rot, blau, weiß und grün.
Des Weiteren sind die Anzeigen auch erhältlich mit gemeinsamer Anode und gemeinsamer Kathode hier muss man aufpassen denn in dem einen Fall muss GND an die PINs 3 und 8 angeschlossen werden und in dem anderen Fall VCC.
Technische Daten der 7 Segmentanzeige
- Abmaße
- Länge - 2 cm
- Breite - 1,35 cm
- Höhe
- inkl. Pins - 1,4 cm
- exkl. Pins - 0,8 cm
Anschluss & Schaltung
In der nachfolgenden Schaltung verwende ich eine 7 Segmentanzeige mit gemeinsamer Kathode, d.h. wenn du eine mit gemeinsamer Anode verwendest musst du hier statt GND, VCC anschließen!
Die 7 Segmentanzeige verfügt über 10 Pins, 8 sind für die Datenleitungen und 2 für GND.
7Segmentanzeige Pinout
7 Segmentanzeige
MakerUNO
10
digitaler Pin D8
9
digitaler Pin D7
8
220 Ohm -> GND
7
digitaler Pin D2
6
digitaler Pin D3
5
digitaler Pin D9
4
digitaler Pin D4
3
220 Ohm -> GND
2
digitaler Pin D5
1
digitaler Pin D6
Schaltung am MakerUNO
Wenn die 7 Segmentanzeige wie oben in der Tabelle angeschlossen wurde, dann sollte die Schaltung wie folgt aussehen.
Schaltung 7 Segmentanzeige
Quellcode
In dem folgenden Beispiel möchte ich nun die Zahlen von 0 bis 9 anzeigen.
Es können neben Zahlen natürlich auch Buchstaben angezeigt werden dazu müssen dann die entsprechenden LEDs an bzw. ausgeschaltet werden.
//Array mit den Pins.
const int PINS = {8, 7, 2, 3, 9, 4, 5, 6};
//Wert für die Pause, welcher der Sketch einlegt,
//wenn die Zahlen von 0 bis 9 angezeigt wurden.
const int PAUSE = 4000;
//Array mit den Möglichen Zahlen und Buchstaben welche auf
//der 7 Segmentanzeige angezeigt werden können.
byte segDigits = {
{ 1,1,1,1,1,1,0 }, // = 0
{ 0,1,1,0,0,0,0 }, // = 1
{ 1,1,0,1,1,0,1 }, // = 2
{ 1,1,1,1,0,0,1 }, // = 3
{ 0,1,1,0,0,1,1 }, // = 4
{ 1,0,1,1,0,1,1 }, // = 5
{ 1,0,1,1,1,1,1 }, // = 6
{ 1,1,1,0,0,0,0 }, // = 7
{ 1,1,1,1,1,1,1 }, // = 8
{ 1,1,1,0,0,1,1 }, // = 9
{ 1,1,1,0,1,1,1 }, // = A
{ 1,0,0,1,1,1,0 }, // = C
{ 1,0,0,1,1,1,1 }, // = E
{ 1,0,0,0,1,1,1 }, // = F
{ 0,1,1,0,1,1,1 }, // = H
{ 0,0,0,1,1,1,0 }, // = L
{ 1,1,0,0,1,1,1 }, // = P
{ 0,1,1,1,1,1,0 }, // = U
{ 0,0,1,1,1,1,1 }, // = b
{ 0,1,1,1,1,0,1 }, // = d
{ 0,0,0,1,1,0,1 } // = c
};
void setup() {
//Die Pins der LEDs als Ausgänge definieren.
for(int i=0;i
Read the full article
1 note
·
View note