Codice
#include <SevenSegment.h>
int latchPin = 10;
int clockPin = 9;
int dataPin = 11;
void setup() {
//set pins to output so you can control the shift register
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}
void loop() {
// count from 0 to 255 and display the number
// on the LEDs
char disp;
for (int numberToDisplay = 0; numberToDisplay < 5; numberToDisplay++) {
// take the latchPin low so
// the LEDs don't change while you're sending in bits:
digitalWrite(latchPin, HIGH);
// digitalWrite(clockPin, LOW);
if (numberToDisplay == 0) {
disp = 0x01;
disp = 0x07;
}
if (numberToDisplay == 1) {
disp = 0x03;
disp = 0x06;
}
if (numberToDisplay == 2) {
disp = 0x5b;
}
if (numberToDisplay == 3) {
disp = 0x4f;
}
if (numberToDisplay == 4) {
disp = 0x66;
}
// shift out the bits:
shiftOut(dataPin, clockPin, MSBFIRST, disp);
digitalWrite(latchPin, LOW);
delay(2000);
}
digitalWrite(latchPin, HIGH);
delay(10000);
}