roborio_digital_io
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| roborio_digital_io [2018/01/22 16:39] – created tell | roborio_digital_io [2018/12/11 22:31] (current) – [Selecting from among more than two alternatives] tell | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| On this page we'll describe the 10 " | On this page we'll describe the 10 " | ||
| + | {{ : | ||
| ====== Introduction ====== | ====== Introduction ====== | ||
| Line 30: | Line 31: | ||
| When configured as an output, the signal pin is driven to 0 volts for a " | When configured as an output, the signal pin is driven to 0 volts for a " | ||
| - | When acting as an input, the RoboRIO interprets any voltage between 0 and 0.8v ad a " | + | When acting as an input, the RoboRIO interprets |
| - | results in either a zero or a one being delivered to the software program. | + | * any voltage between 0 and 0.8v is a " |
| + | * a voltage between 2.0v and 5.5v i a " | ||
| + | * A voltage in between those ranges results in either a zero or a one being delivered to the software program. We generally want to avoid this indeterminate region. | ||
| - | There is a " | + | There is a " |
| - | To cause a DIO to be read as " | + | So, to cause a DIO to be read as " |
| + | |||
| + | {{ : | ||
| - | [picture needed] | ||
| ====== Software ====== | ====== Software ====== | ||
| Here's a Java code fragment: | Here's a Java code fragment: | ||
| - | '' | + | <code java> |
| | | ||
| Line 68: | Line 72: | ||
| } | } | ||
| } | } | ||
| - | '' | + | </ |
| + | |||
| + | |||
| + | Notice somthing there that is true of most simple test programs: | ||
| + | mySwitch = new DigitalInput(1); | ||
| + | |||
| + | This creates an object which represents our DIO pin in software. | ||
| + | associtated with DIO number 1. | ||
| + | |||
| + | The other interesting line is: | ||
| + | switch_now = mySwitch.get(); | ||
| + | which reads the current state of the DIO and stores it in a boolean variable called '' | ||
| + | We can then use switch_now in an '' | ||
| + | |||
| + | |||
| + | |||
| + | |||
| Line 77: | Line 98: | ||
| + | |||
| + | |||
| + | What if we want to select between more than two choices? | ||
| ====== Conclusion ====== | ====== Conclusion ====== | ||
| + | |||
| This discussion also applies to the 16 additional DIO pins located on the roborio expansion connector. | This discussion also applies to the 16 additional DIO pins located on the roborio expansion connector. | ||
roborio_digital_io.1516657160.txt.gz · Last modified: 2018/01/22 16:39 by tell
