Digital IO Agggggggggggg!

My team can’t seem to be able to get the digital IO ports working. We made a printf statement that just displays the state of digital_io_01 and also made the switch 2 led = to the state of digital_io_01. The led and the terminal window both say that digital_io_01 = 1. At first we thought that this was weird because there was no switch or anything attached that would close the circuit and make it 1. We attached a pwm cable and tried jumpering red to white and then tried to jumper black to white but there was no change in the state of digital_io_01. We have it configured as an input but we can’t seem to get the state of digital_io_01 to change from 1. How are we supposed to hook switches and other sensors that run on an on off basis to the Digital IO pins and get them to work. Also, in an unrelated question, how are we supposed to hook up a pot or other analogue sensor to the analogue input pins?

Second question first. The Robot Controller Reference is your friend. Check page 9.

First question. This should be working. So I have a few questions for you. Are you certain you’re properly setting it to an input? Are you sure you’re not setting it to an output somewhere just after that? Are you sure you’re not sending a value to the variable in you code anyways? And finally, are you sure the PWM is plugged in the right way and in the right port?

Otherwise, yes shorting black to white should change the input from 1 to 0. The input is 1 normally because the the pin has a pull up resistor on it that pulls the value up to 5V when there’s nothing connected.

digital_io_01 is used to set the pin to either INPUT or OUTPUT.

To actually read it once you have it set to input, you read it through rc_dig_in01.

If you were to set it to output instead, you set the value to rc_dig_out01.

digital_io_01 is used to set the pin to either INPUT or OUTPUT.

To actually read it once you have it set to input, you read it through rc_dig_in01.

If you were to set it to output instead, you set the value to rc_dig_out01.

Michael

You just solved one nagging bug from our 2006 code. Our 2007 code thanks you.