-
Notifications
You must be signed in to change notification settings - Fork 2
/
HDSP-Arduino.ino
111 lines (102 loc) · 2.35 KB
/
HDSP-Arduino.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
Demo Code for HDSP 2111 using SN74LS595N
Matt Joyce < [email protected] >
Thanks to Mark Tabry for assistance
*/
//Pin connected to latch pin (ST_CP) of 74HC595
const int latchPin = 8;
//Pin connected to clock pin (SH_CP) of 74HC595
const int clockPin = 12;
////Pin connected to Data in (DS) of 74HC595
const int dataPin = 11;
const int ce = 5;
const int wr = 6;
const int a2 = 4;
const int a1 = 3;
const int a0 = 2;
const int rst = 10;
const int a3 = 9;
int incomingByte = 0;
void setup() {
//set pins to output because they are addressed in the main loop
pinMode(latchPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(a0, OUTPUT);
pinMode(a1, OUTPUT);
pinMode(a2, OUTPUT);
pinMode(a3, OUTPUT);
pinMode(rst, OUTPUT);
pinMode(ce, OUTPUT);
pinMode(wr, OUTPUT);
digitalWrite(ce, HIGH);
digitalWrite(wr, HIGH);
resetDisplay();
}
void resetDisplay() {
digitalWrite(rst, LOW);
delayMicroseconds(1);
digitalWrite(rst,HIGH);
delayMicroseconds(150);
digitalWrite(a3, HIGH);
}
void writeDisplay(char *input) {
// Serial.println(input);
for (int i=0; i<8; i++) {
digitalWrite(a0, (1&i)!=0?HIGH:LOW);
digitalWrite(a1, (2&i)!=0?HIGH:LOW);
digitalWrite(a2, (4&i)!=0?HIGH:LOW);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, input[i] );
digitalWrite(latchPin, HIGH);
delay(1);
digitalWrite(ce, LOW);
delay(1);
digitalWrite(wr, LOW);
delay(1);
digitalWrite(wr, HIGH);
delay(1);
digitalWrite(ce, HIGH);
delay(1);
}
}
void scrollDisplay(char *words) {
char buffer[9];
int i = 0;
while(words[i] != 0){
boolean blank = false;
for (int j = 0; j<8; j++) {
if ( !blank && words[i+j] == 0 ) {
blank = true;
}
if ( blank ) {
buffer[j] = ' ';
}
else {
buffer[j] = words[i+j];
}
}
buffer[8]=0;
writeDisplay(buffer);
delay(200);
i++;
}
}
void startUpMessage() {
char startUp[] = "Standby^";
writeDisplay(startUp);
delay(3000);
char next[] = "---------";
writeDisplay(next);
delay(3000);
}
void loop() {
char intro[] = " Hello World! 1234567890 !@#$%^&*() ";
startUpMessage();
scrollDisplay(intro);
delay(2000);
char msg[] = "********";
writeDisplay(msg);
delay(2000);
resetDisplay();
}