forked from Nakazoto/CenturionComputer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ROM_Reader.ino
77 lines (64 loc) · 1.61 KB
/
ROM_Reader.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
const int clk = 13;
const int rst = 12;
const int d0 = 2;
const int d1 = 3;
const int d2 = 4;
const int d3 = 5;
const int d4 = 6;
const int d5 = 7;
const int d6 = 8;
const int d7 = 9;
int cnt = 0;
int nl = 0;
void setup() {
Serial.begin(9600);
pinMode (clk, OUTPUT);
pinMode (rst, INPUT);
pinMode (d0, INPUT);
pinMode (d1, INPUT);
pinMode (d2, INPUT);
pinMode (d3, INPUT);
pinMode (d4, INPUT);
pinMode (d5, INPUT);
pinMode (d6, INPUT);
pinMode (d7, INPUT);
digitalWrite(clk, LOW);
}
void loop() {
if (digitalRead(rst) == HIGH) {
//4096 = 12bits, 2048 = 11bits, 1024 = 10bits, 512 = 9bits, 256 = 8bits
if (cnt < 256) {
cnt++;
int sum = 0;
if (digitalRead(d0) == HIGH) {sum += 1;}
if (digitalRead(d1) == HIGH) {sum += 2;}
if (digitalRead(d2) == HIGH) {sum += 4;}
if (digitalRead(d3) == HIGH) {sum += 8;}
if (digitalRead(d4) == HIGH) {sum += 16;}
if (digitalRead(d5) == HIGH) {sum += 32;}
if (digitalRead(d6) == HIGH) {sum += 64;}
if (digitalRead(d7) == HIGH) {sum += 128;}
if (nl >= 8) {
nl = 0;
Serial.println();
}
if (sum < 16) {Serial.print("0");}
Serial.print(sum, HEX);
if (nl < 7) {Serial.print(" ");}
nl++;
digitalWrite(clk, HIGH);
delay(1);
digitalWrite(clk, LOW);
delay(1);
} else {
delay (1000);
}
} else {
Serial.println();
Serial.print("Break");
Serial.println();
cnt = 0;
nl = 0;
delay (1000);
}
}