/*
82s129 Arduino reader
Originally by Vincenzo Femia (enzofemia@gmail.com)
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();
}