With the need to drive some electronics with open collector / open drain outputs from Arduino, I just realized that it may just be possible to emulate open collectors with a bit of smart programming. Maybe I'm not the first to come up with this idead, maybe someone has tried it before and has good or bad experience with this method.
The idea is to use the ATmega's internal pull up resistor when in HIGH state as follows: - To emulate an open collecter / open drain output LOW: => pinMode( n , OUTPUT ); digitalWrite( n , LOW );
- To emulate an open collector / open drain output HIGH: => pinMode( n , INPUT ); digitalWrite( n , HIGH );
If this works, it'd save an external resistor, transistor and the programmed logic does not need to be inverted.
Thoughts anyone? Anyone tried it before? Caveats? ...