Hey guys
Just wondering what you think of this. I haven't been able to find anything similar so let me know if someone has tried this before!
I've rigged up an arduino to send data to my NES through the controller port. So far I'm able to able to:
- send text from computer and have it display on screen like a text console
- send bytes representing frequencies to play simple melodies
- drag&drop an image into a program to make nes-friendly tiles then send them to the NES, overwriting the pattern table (CHR RAM), and then writing to the nametable to show the tiles on the screen as they were displayed in the computer program (*not perfect)
How it works:
I soldered a little port in the bottom of an nes controller with 1 wire for each button, plus 1 ground (9 pins) so that if you connect a wire from one of the 8 button wires to the 9th (ground), it is equivalent to what happens when you press a button.
I connected the controller to an arduino using darlington transistors which work sort of like relays so that when I change the state of a pin on the arduino I can open and close a circuit. You can't just hook the buttons up to an arduino output pin directly, you only want to allow electricity to go through (button pressed) or not (button not pressed) rather than sending electricity to the controller from the arduino. You want it so that you can tell the arduino to set an output pin to 1 (electricity going out the pin) and that is the signal for the darlington transistor to close the gap as if you had pressed a button. The darlington transistors were pretty cheap and easy to order.
I open and close a circuit for each button in the controller. Because there are 8 buttons which can be in a state of 0 (not pressed) and 1 (pressed), I can take an 8-bit value (0 to 255) and break it down into 8 bits and then "press" the controller buttons accordingly. The wiring does not interfere with pressing buttons on the actual controller - if the arduino is not manipulating the state of the buttons, the extra wires stay open, so the controller can be used normally when the arduino is not plugged in to it.
In the case of the text console, I have an nes program where the background tileset contains all the basic ASCII characters. Their index in the pattern table is their ascii code.
So say I have a tile at position 65 in the pattern table that looks like the letter A, and 65 is the ascii code for A. I send an "A" (65) to the arduino from a computer, it turns the 65 into 01000001. If you don't know how binary works you could say that each bit in that sequence is "worth" a certain amount. The amount each bit is worth goes in this order: 128,64,16,8,4,2,1. So we have one bit worth 64 and one bit worth 1 in the example of the letter A (65).
The button order is A, B, Select, Start, Up, Down, Left, Right.
So in this case the arduino will press/not press the buttons as follows:
A = not pressed (128)
B = PRESSED (64)
Select = not pressed (32)
Start = not pressed (16)
Up = not pressed (8)
Down = not pressed (4)
Left = not pressed (2)
Right = PRESSED (1)
....... and 64+1 = 65 = A
On the nes I have a program that reads the state of all the buttons and recreates the byte. In the case above, it would start out with a value of 0. Since B is pressed it would add 64, and since Right is pressed it would add 1. So it would end up with the value 65. It puts this value in the nametable and since position 65 in the pattern table contains a pattern that looks like the letter A, the letter A gets displayed on screen!
Parts
Arduino + 8 darlington transistors + 8 resistors + wires + soldering 8 points in controller
python program to communicate with arduino. python program sends text, music, or chr tile data.
processing (.org) program for drag&drop conversion of image to nes-friendly format, creates tile data that python script can send to arduino
nes program to interpret controller presses as bytes (on flash cart)
Problems
- A few bytes are reserved for control codes so when you send new CHR data for displaying images, there are certain values you can't send because they're reserved.
- The arduino and NES are not exactly in sync so sometimes the nes gets the wrong value if the arduino was in the middle of switching to a new byte when the NES read the state of the buttons. Probably about 1 out of every 300 bytes comes out wrong but I'm hoping to add a couple more wires so that the arduino can tell when the NES strobes the controller and switch to the next value perfectly between reads.
- This is the second thing I've ever tried to program on the NES and the first didn't come out too good. I could work around the control code problem with some better code but I'm completely new to 6502 asm and the nes.
- Trying to think of a way to send data out of the nes to the arduino for two-way communication
The Rest
Let me know if you've seen/done something like this before, I'd love some tips. I really don't know if this will even interest anyone. I'll post some pictures/videos/code if it does.
If you're familiar with the arduino, you can solder the wires in the controller, and you can pick up some darlington transistors you could probably have this up and running in about an hour. I'm not sure what you could use it for but if it was a bit more solid you could send pretty much anything you want from a computer to an NES.
Just wondering what you think of this. I haven't been able to find anything similar so let me know if someone has tried this before!
I've rigged up an arduino to send data to my NES through the controller port. So far I'm able to able to:
- send text from computer and have it display on screen like a text console
- send bytes representing frequencies to play simple melodies
- drag&drop an image into a program to make nes-friendly tiles then send them to the NES, overwriting the pattern table (CHR RAM), and then writing to the nametable to show the tiles on the screen as they were displayed in the computer program (*not perfect)
How it works:
I soldered a little port in the bottom of an nes controller with 1 wire for each button, plus 1 ground (9 pins) so that if you connect a wire from one of the 8 button wires to the 9th (ground), it is equivalent to what happens when you press a button.
I connected the controller to an arduino using darlington transistors which work sort of like relays so that when I change the state of a pin on the arduino I can open and close a circuit. You can't just hook the buttons up to an arduino output pin directly, you only want to allow electricity to go through (button pressed) or not (button not pressed) rather than sending electricity to the controller from the arduino. You want it so that you can tell the arduino to set an output pin to 1 (electricity going out the pin) and that is the signal for the darlington transistor to close the gap as if you had pressed a button. The darlington transistors were pretty cheap and easy to order.
I open and close a circuit for each button in the controller. Because there are 8 buttons which can be in a state of 0 (not pressed) and 1 (pressed), I can take an 8-bit value (0 to 255) and break it down into 8 bits and then "press" the controller buttons accordingly. The wiring does not interfere with pressing buttons on the actual controller - if the arduino is not manipulating the state of the buttons, the extra wires stay open, so the controller can be used normally when the arduino is not plugged in to it.
In the case of the text console, I have an nes program where the background tileset contains all the basic ASCII characters. Their index in the pattern table is their ascii code.
So say I have a tile at position 65 in the pattern table that looks like the letter A, and 65 is the ascii code for A. I send an "A" (65) to the arduino from a computer, it turns the 65 into 01000001. If you don't know how binary works you could say that each bit in that sequence is "worth" a certain amount. The amount each bit is worth goes in this order: 128,64,16,8,4,2,1. So we have one bit worth 64 and one bit worth 1 in the example of the letter A (65).
The button order is A, B, Select, Start, Up, Down, Left, Right.
So in this case the arduino will press/not press the buttons as follows:
A = not pressed (128)
B = PRESSED (64)
Select = not pressed (32)
Start = not pressed (16)
Up = not pressed (8)
Down = not pressed (4)
Left = not pressed (2)
Right = PRESSED (1)
....... and 64+1 = 65 = A
On the nes I have a program that reads the state of all the buttons and recreates the byte. In the case above, it would start out with a value of 0. Since B is pressed it would add 64, and since Right is pressed it would add 1. So it would end up with the value 65. It puts this value in the nametable and since position 65 in the pattern table contains a pattern that looks like the letter A, the letter A gets displayed on screen!
Parts
Arduino + 8 darlington transistors + 8 resistors + wires + soldering 8 points in controller
python program to communicate with arduino. python program sends text, music, or chr tile data.
processing (.org) program for drag&drop conversion of image to nes-friendly format, creates tile data that python script can send to arduino
nes program to interpret controller presses as bytes (on flash cart)
Problems
- A few bytes are reserved for control codes so when you send new CHR data for displaying images, there are certain values you can't send because they're reserved.
- The arduino and NES are not exactly in sync so sometimes the nes gets the wrong value if the arduino was in the middle of switching to a new byte when the NES read the state of the buttons. Probably about 1 out of every 300 bytes comes out wrong but I'm hoping to add a couple more wires so that the arduino can tell when the NES strobes the controller and switch to the next value perfectly between reads.
- This is the second thing I've ever tried to program on the NES and the first didn't come out too good. I could work around the control code problem with some better code but I'm completely new to 6502 asm and the nes.
- Trying to think of a way to send data out of the nes to the arduino for two-way communication
The Rest
Let me know if you've seen/done something like this before, I'd love some tips. I really don't know if this will even interest anyone. I'll post some pictures/videos/code if it does.
If you're familiar with the arduino, you can solder the wires in the controller, and you can pick up some darlington transistors you could probably have this up and running in about an hour. I'm not sure what you could use it for but if it was a bit more solid you could send pretty much anything you want from a computer to an NES.