Originally Posted by nuclearnerd
Since you put a mechanical switch on the diagram, for bonus points you could add a wiring diagram for an NPN switch (infrared, ultrasonic, inductive etc.) like this one
. They are trickier because you they typically run on 12V (so you need to get power from the VRM, not the Rio) and the switching state may not match the threshold of the Rio's digital inputs so it might be easier to wire it to the Rio's analog input. If it sounds like I don't fully know what I'm talking about, it's true - so a wiring diagram would be helpful
Someone with more electrical expertise than me can put together a sketch.
Yes, showing how to connect these NPN-output devices would be helpful.
The RoboRio's switching thresholds should not be a problem with the NPN-output devices since the output voltages should be just below the 12 V supply when in the Hi state and very close to zero V when in the Lo state.
The RoboRio Spec Sheet
states that Analogue Inputs have a range of 0~5 V and are protected for +- 16V. While the Analogue Inputs will survive being connected to +12 V, it is not good practice. It would be better to use a resistive divider to drop the Hi level to below 5 V so that the protection devices are not active for long periods of time. It would then not matter whether it is connected to one of the Analogue Inputs or one of the Digital Inputs.
The Digital Inputs are "compatible" with 5 V inputs and have 40 KOhm pullup resistors connected to the internal 3.3 V supply. I have never found any references to protection devices on the DIO's. It is not clear if they are guaranteed to survive being connected to anything higher than 5~6 V.