Page : | [ 1 ] | [ 2 ] | [ 3 ] | [ 4 ] |
Here's a bit of code to do some simple scrolling.
char buf[16] = "";
int point = 0;
int pos = 0;
String str = " HELLO THIS SEEMS TO WORK AND SCROLL OK !! ";
const byte _A0 = 13;
const byte _A1 = 4;
const byte _A2 = 33;
const byte _A3 = 25;
const byte _D0 = 17;
const byte _D1 = 27;
const byte _D2 = 26;
const byte _D3 = 21;
const byte _D4 = 22;
const byte _D5 = 19;
const byte _D6 = 18;
const byte _WR = 16;
const byte _BL = 23;
const byte _CLR = 32;
void setup() {
Serial.begin(115200);
pinMode(_A0, OUTPUT);
pinMode(_A1, OUTPUT);
pinMode(_A2, OUTPUT);
pinMode(_A3, OUTPUT);
pinMode(_D0, OUTPUT);
pinMode(_D1, OUTPUT);
pinMode(_D2, OUTPUT);
pinMode(_D3, OUTPUT);
pinMode(_D4, OUTPUT);
pinMode(_D5, OUTPUT);
pinMode(_D6, OUTPUT);
pinMode(_WR, OUTPUT);
pinMode(_BL, OUTPUT);
pinMode(_CLR, OUTPUT);
digitalWrite(_BL, HIGH);
digitalWrite(_CLR, LOW);
delay(20);
digitalWrite(_CLR, HIGH);
delay(20);
digitalWrite(_WR, HIGH);
delay(20);
}
unsigned long intervalPreviousMillis = 0;
const long interval = 300;
void loop() {
unsigned long currentMillis = millis();
if ((currentMillis - intervalPreviousMillis) >= interval) {
intervalPreviousMillis = currentMillis;
char x;
for (int i = 0;i < 16; i++){
if (point + i >= str.length()){
x = str[(point + i) - str.length()];
} else {
x = str[point + i];
}
switch(i){
// display 1
case 0:
displayChar(x, 3, 0);
break;
case 1:
displayChar(x, 2, 0);
break;
case 2:
displayChar(x, 1, 0);
break;
case 3:
displayChar(x, 0, 0);
break;
// display 2
case 4:
displayChar(x, 3, 1);
break;
case 5:
displayChar(x, 2, 1);
break;
case 6:
displayChar(x, 1, 1);
break;
case 7:
displayChar(x, 0, 1);
break;
// display 3
case 8:
displayChar(x, 3, 2);
break;
case 9:
displayChar(x, 2, 2);
break;
case 10:
displayChar(x, 1, 2);
break;
case 11:
displayChar(x, 0, 2);
break;
// display 4
case 12:
displayChar(x, 3, 3);
break;
case 13:
displayChar(x, 2, 3);
break;
case 14:
displayChar(x, 1, 3);
break;
case 15:
displayChar(x, 0, 3);
break;
}
}
point++;
if (point >= str.length()){
point = 0;
}
}
}
void displayChar(char myChar, int myPos, byte myDisp){
switch (myDisp){
case 0:
digitalWrite(_A2, HIGH);
digitalWrite(_A3, HIGH);
break;
case 1:
digitalWrite(_A2, LOW);
digitalWrite(_A3, HIGH);
break;
case 2:
digitalWrite(_A2, HIGH);
digitalWrite(_A3, LOW);
break;
case 3:
digitalWrite(_A2, LOW);
digitalWrite(_A3, LOW);
break;
}
switch (myPos){
case 0:
digitalWrite(_A0, LOW);
digitalWrite(_A1, LOW);
break;
case 1:
digitalWrite(_A0, HIGH);
digitalWrite(_A1, LOW);
break;
case 2:
digitalWrite(_A0, LOW);
digitalWrite(_A1, HIGH);
break;
case 3:
digitalWrite(_A0, HIGH);
digitalWrite(_A1, HIGH);
break;
}
digitalWrite(_D0, (myChar >> 0) & 1);
digitalWrite(_D1, (myChar >> 1) & 1);
digitalWrite(_D2, (myChar >> 2) & 1);
digitalWrite(_D3, (myChar >> 3) & 1);
digitalWrite(_D4, (myChar >> 4) & 1);
digitalWrite(_D5, (myChar >> 5) & 1);
digitalWrite(_D6, (myChar >> 6) & 1);
digitalWrite(_WR, LOW);
digitalWrite(_WR, HIGH);
}
(Page 4 of 4) | ||