-
Notifications
You must be signed in to change notification settings - Fork 0
/
HMDL2416.ino
75 lines (62 loc) · 1.27 KB
/
HMDL2416.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
/* HMDL2416 --- test HP LED display */
#include <avr/io.h>
#define WR_PIN 7
#define A0_PIN 8
#define A1_PIN 9
#define CS_PIN 10
void setup(void)
{
int i;
pinMode(WR_PIN, OUTPUT);
pinMode(A0_PIN, OUTPUT);
pinMode(A1_PIN, OUTPUT);
pinMode(CS_PIN, OUTPUT);
for (i = 0; i < 7; i++)
pinMode(i, OUTPUT);
digitalWrite(WR_PIN, HIGH);
digitalWrite(CS_PIN, HIGH);
digitalWrite(A0_PIN, LOW);
digitalWrite(A1_PIN, LOW);
for (i = 0; i < 7; i++)
digitalWrite(i, LOW);
}
void loop(void)
{
int ch;
int i;
for (ch = '!'; ch <= '\\'; ch++) {
for (i = 0; i < 4; i++) {
HMDL2416Write(3 - i, ch + i);
}
delay(300);
}
}
void HMDL2416Write(int digit, int ch)
{
switch (digit) {
case 0:
digitalWrite(A0_PIN, LOW);
digitalWrite(A1_PIN, LOW);
break;
case 1:
digitalWrite(A0_PIN, HIGH);
digitalWrite(A1_PIN, LOW);
break;
case 2:
digitalWrite(A0_PIN, LOW);
digitalWrite(A1_PIN, HIGH);
break;
case 3:
digitalWrite(A0_PIN, HIGH);
digitalWrite(A1_PIN, HIGH);
break;
}
PORTD = ch | 0x80;
digitalWrite(CS_PIN, LOW);
delayMicroseconds(2);
digitalWrite(WR_PIN, LOW);
delayMicroseconds(2);
digitalWrite(WR_PIN, HIGH);
delayMicroseconds(2);
digitalWrite(CS_PIN, HIGH);
}