I'm working on a POC of using an Arduino as a Gamecube controller. According to this webpage the only actual data transfer occurs over pin 2 in the port, which operates at 3.43V and is bidirectional. How would I set up a compatible bidirectional data pin with Arduino?
run the Arduino at that voltage, and switch pinmode between input and output as appropriate.
It's really that simple? Sweet. Thanks!
I don't know anything about the GameCube but it's "dangerous" to connect two outputs together (i.e. if both devices transmit at the same time).
The exception would be open-collector outputs which create a wired-or connection (technically NOR) where one or more outputs can safely pull-down the signal line at the same time. (The Arduino does not have open-collector outputs.)
For example, if you connect two Arduino outputs together and one goes high when the other goes low, the two outputs will "fight" each other, you'll get excessive current, and you'll possibly damage your Arduino.
The safest thing is probably to add a resistor (1K or so) in series with the Arduino I/O pin to limit the current to safe levels.
A 270 ohm (19 mA) resistor would be adequate, allowing fastest response.
Do I worry too much? I would advise novices to put off any project that needed you to switch the mode of a pin back and forth between input and output.
At least… I think it could be done, though I admit I’m not sure… maybe someone will see this and either supply a circuit, or say the idea is just daft to begin with… interpose a little circuit between your “thing” with the bi-directional pin and your Arduino. (Call this “the interface circuit”.
The interface circuit would have one input/output to connect to your thing, AND an input, to be driven by the Arduino, AND (third pin) an output, to feed a DIFFERENT pin on the Arduino.
So Arduino would send to and receive from your thing over two pins. How everyone would know whether your thing was sending or receiving at a particular moment would take some working out, probably different in different cases of connected “things”.
PS, if you are wanting to connect a DS1820 Dallas 1-Wire chip, which both sends and receives data, just use the library, and use it with confidence, in spite of what I said about bi-directional pins being hazardous.
Making a Nintendo Gamecube Controller (that uses true bidirectional I/O) with an arduino , which has to be reconfigured to change data direction , may be an uphill battle. In my experience, a POC is never attempted until a feasibility study is performed. There's a lot of details to consider, not the least of which is you will probably need either a very fast storage scope or a logic analyzer. It will not be easy.
The transfer speed is rather fast at around 4us per bit. As with the N64 controller, a low bit is signaled by a 3us low followed by 1us high, and a high bit is signaled by 1us low followed by 3us high. Yes, it's just like the N64 controller!
Good luck with that. The spec for delayMicroseconds() is a minimum of 4. I couldn't find any information about the spec (if there is one) for the data direction change time.
I hope you haven't already committed to doing this. If by some miracle you manage to do it , you should definitely post the project in the Exhibition Gallery. (preferably with software and schematics, but those are optional I believe for that topic category).
You might want to think about how you are going to get a 1uS delay. (FYI, I think a NOP is 140 nS)
Arduino does not have true bidirectional pins, as the pin functionality is aimed at applications where you need either one of the functions. The ability to switch between the 2 modes is build in to save pins count and add to to usability. In non critical applications, it is covenient to switch between modes, for example in elaborated matrix readings.
Communications electronics usually have true bidirectional pins, as they are constructed to be active only at the instant of sending information. The rest of the time it will "listen" to the communication wire as an input, not to disturb any on-going communication by suddenly transmitting out in the face of this on-going communication.