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
/*
  82s129 Arduino reader
  Originally by Vincenzo Femia ([email protected])
  Shortened, using arrays and for loops.
  I'm sure this can be shortened a lot more.
 */
byte indirizzo=0;//"indirizzo" is Italian for "address" :-)
boolean a[8];//address bits
boolean o[4];//data bits

void setup()
{
  for(int i = 2; i < 10; i++){
    pinMode(i, OUTPUT); //set pins for address
  }
  for(int j = 10; j < 14; j++){
    pinMode(j, INPUT); //set pins for data
  }
  Serial.begin(9600); //start serial communication
}

void loop()
{

    for (indirizzo=0; indirizzo<256; indirizzo++)// from 00 to FF address
   {
     for(int i = 0; i < 8; i++)
     {
      a[i] = bitRead(indirizzo, i); //read status bit of address...
       if(a[i] == 1) //and set outputs...
       {
         digitalWrite((i+2), HIGH); //we add 2 to i because the output pins go from 2 to 9, not 0 to 7.
       } else {
         digitalWrite((i+2), LOW);
       }
     }

    //Wait so outputs can be set by 82S129
     delay (50);
     for (int i = 0; i < 4; i++)
     {
       o[i] = digitalRead(i + 10); //read the outputs.
     }
     //Setting serial communication
     //Write in binary ASCII address read and "->"
     for (int i = 7; i >= 0; i--){
       Serial.print(a[i]);
     }
     Serial.print(" -> ");

//Write in binary ASCII output nibble
     for(int i = 3; i >= 0; i--){
       Serial.print(o[i]);
     }
     Serial.println(""); //newline.
    }
    Serial.println("ROM has been read.");
    Serial.end();
}