Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const char ADDR[] = {22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52}; //address pins connected to arduino.
- const char DATA[] = {39, 41, 43, 45, 47, 49, 51, 53}; //data pins connected to arduino.
- #define CLOCK 2 //pulse from the clock circuit is connected to pin 2 of the arduino.
- #define READ_WRITE 3 //the read/write pin on the processor (pin 34) is connected to pin 3 on the arduino.
- void setup() {
- for (int n = 0; n < 16; n += 1) {
- pinMode(ADDR[n], INPUT); //setting all the address pins to inputs.
- }
- for (int n = 0; n < 8; n += 1) {
- pinMode(DATA[n], INPUT); //setting all the data pins to inputs.
- }
- pinMode(CLOCK, INPUT); //setting the clock and read/write pins to inputs.
- pinMode(READ_WRITE, INPUT);
- attachInterrupt(digitalPinToInterrupt(CLOCK), onClock, RISING); //trigger an interrupt when a clock pulse is received and call the onClock function.
- Serial.begin(57600); //'baud rate'. not a clue what it does.
- }
- void onClock() { //execute all the code in this function when the onClock function is called.
- char output[15];
- unsigned int address = 0;
- for (int n = 0; n < 16; n += 1) {
- int bit = digitalRead(ADDR[n]) ? 1 : 0; //read from an address pin. if 5v, return 1. if 0v, return 0.
- Serial.print(bit); //print the bit read from the the address pin to the serial monitor.
- address = (address << 1) + bit;
- }
- Serial.print(" "); //prints white space for that nice text formatting.
- unsigned int data = 0;
- for (int n = 0; n < 8; n += 1) {
- int bit = digitalRead(DATA[n]) ? 1 : 0; //read from all the data pins. if 5v, return 1. if 0v, return 0.
- Serial.print(bit); //print the bit read from the the address pin to the serial monitor.
- data = (data << 1) + bit;
- }
- sprintf(output, " %04x %c %02x", address, digitalRead(READ_WRITE) ? 'r' : 'W', data); //prints the data read from the address and data lines and prints it in
- Serial.println(output); //hexadecimal. this will make it much easier to interpret instructions.
- } //also prints an 'r' if the data lines are reading or a 'W' if writing.
- void loop() {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement