antitheft159
commited on
Commit
•
bbbcc47
1
Parent(s):
b3534fd
Upload DRHH.159.ino
Browse files- DRHH.159.ino +42 -0
DRHH.159.ino
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const char ADDR[] = {22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52};
|
2 |
+
const char DATA[] = {39, 41, 43, 45, 47, 49, 51, 53};
|
3 |
+
#define CLOCK 2
|
4 |
+
#define READ_WRITE 3
|
5 |
+
void setup() {
|
6 |
+
// put your setup code here, to run once:
|
7 |
+
for (int n = 0; n < 16; n += 1) {
|
8 |
+
pinMode(ADDR[n], INPUT);
|
9 |
+
}
|
10 |
+
for (int n = 0; n < 8; n += 1) {
|
11 |
+
pinMode(DATA[n], INPUT);
|
12 |
+
}
|
13 |
+
pinMode(CLOCK, INPUT);
|
14 |
+
pinMode(READ_WRITE, INPUT);
|
15 |
+
attachInterrupt(digitalPinToInterrupt(CLOCK), onClock, RISING);
|
16 |
+
Serial.begin(57600);
|
17 |
+
}
|
18 |
+
|
19 |
+
void onClock() {
|
20 |
+
char output[15];
|
21 |
+
|
22 |
+
unsigned int address = 0;
|
23 |
+
for(int n = 0; n < 16; n += 1) {
|
24 |
+
int bit = digitalRead(ADDR[n]) ? 1 : 0;
|
25 |
+
Serial.print(bit);
|
26 |
+
address = (address << 1) + bit;
|
27 |
+
}
|
28 |
+
Serial.print(" ");
|
29 |
+
unsigned int data = 0;
|
30 |
+
for(int n = 0; n < 8; n +=1) {
|
31 |
+
int bit = digitalRead(DATA[n]) ? 1 : 0;
|
32 |
+
Serial.print(bit);
|
33 |
+
data = (data << 1) + bit;
|
34 |
+
}
|
35 |
+
sprintf(output, " %04x %c %02x", address, digitalRead(READ_WRITE) ? 'r' : 'W', data);
|
36 |
+
Serial.println(output);
|
37 |
+
}
|
38 |
+
|
39 |
+
void loop() {
|
40 |
+
// put your main code here, to run repeatedly:
|
41 |
+
|
42 |
+
}
|