PLCD558x
Připojení k Arduinu
Pin PLCD5583 | Název pinu PLCD5583 | Pin Arduino |
---|
1 | RST | A0 |
2 | FL | A1 |
3 | A0 | A2 |
4 | A1 | A3 |
5 | A2 | A4 |
6 | A3 | A5 |
7 | NC | – |
8 | NC | – |
9 | NC | – |
10 | NC | – |
11 | CLKSEL | – |
12 | CLK I/O | – |
13 | WR | A2 |
14 | Vcc | 5V |
15 | GND (supply) | GND |
16 | GND (logic) | GND |
17 | CE | A3 |
18 | NC | – |
19 | D0 | 6 |
20 | D1 | 7 |
21 | – | – |
22 | – | – |
23 | D2 | 8 |
24 | D3 | 9 |
25 | D4 | 10 |
26 | D5 | 11 |
27 | D6 | 12 |
28 | D7 | 13 |
Zdrojový kód pro Arduino
// sketch based on source from: https://github.com/abzman/PLCD5583
int addrPins[4] = {2, 3, 4, 5};
int dataPins[8] = {6, 7, 8, 9, 10, 11, 12, 13};
int resetPin = A0; //active low
int flashPin = A1; //active low
int writePin = A2; //active low
int enablePin = A3; //active low
char msg[] = " *** PLCD5583 DEMO *** MORE DISPLAYS ON CTVRTKY.CZ/SBIRKA-DISPLEJU-LED ";
int brightness = 1;
void setup() {
for (int i = 0; i < 4; ++i) pinMode(addrPins[i], OUTPUT);
for (int i = 0; i < 8; ++i) pinMode(dataPins[i], OUTPUT);
pinMode(resetPin, OUTPUT);
pinMode(flashPin, OUTPUT);
pinMode(writePin, OUTPUT);
pinMode(enablePin, OUTPUT);
digitalWrite(resetPin, HIGH);
digitalWrite(flashPin, HIGH);
digitalWrite(writePin, HIGH);
digitalWrite(enablePin, LOW);
setCommand();
for (byte i = 0; i < (sizeof(msg) / sizeof(char)); i++) {
writeLED(msg[i + 7], 7);
writeLED(msg[i + 6], 6);
writeLED(msg[i + 5], 5);
writeLED(msg[i + 4], 4);
writeLED(msg[i + 3], 3);
writeLED(msg[i + 2], 2);
writeLED(msg[i + 1], 1);
writeLED(msg[i], 0);
if (i == (sizeof(msg) / sizeof(char)) - 1) {
i = 0;
}
delay(350);
}
}
boolean isBitSet(byte data, int i) {
return ((data & (1 << i)) >> i);
}
void write(byte data) {
for (int i = 0; i < 8; ++i)
digitalWrite(dataPins[i], isBitSet(data, i));
latch();
}
void latch()
{
//Latch out our write
digitalWrite(writePin, LOW);
delay(10);
digitalWrite(writePin, HIGH);
}
void writeLED(char c, int digit) {
//Address Decode
digitalWrite(addrPins[0], (digit % 2) ? HIGH : LOW);
digitalWrite(addrPins[1], ((digit / 2) % 2) ? HIGH : LOW);
digitalWrite(addrPins[2], (digit > 3) ? HIGH : LOW);
digitalWrite(addrPins[3], HIGH);
//Write our character
write(c);
}
void setCommand()
{
digitalWrite(addrPins[3], LOW);
if (brightness < 8)
{
digitalWrite(dataPins[2], (brightness > 3) ? LOW : HIGH);
digitalWrite(dataPins[1], ((brightness / 2) % 2) ? LOW : HIGH);
digitalWrite(dataPins[0], (brightness % 2) ? LOW : HIGH);
latch();
}
digitalWrite(addrPins[3], HIGH);
}
void loop() {
}
Demo video