loading
 
Read Inputs using Arduino Mega Module
eJMO from United States  [3 posts]
8 year
I was under the impression that if you want to read the state of a digital pin (for example Pin 51) using the Arduino Mega module, you would check the first pin # box, and add the variable name.  The variable must be declared in the script as a boolean or as an integer.

I have been able to output on the digital pins without a problem, but have never been successful at reading a pin.  Must the bit value be changed somehow to read the pin state?  Are the input pins always set to HIGH by default?



Steven Gentner from United States  [1446 posts] 8 year
You do need to specify a variable in the appropriate pin # box but you do NOT need to declare or use the variable anywhere ... the module will create and populate that variable as appropriate. In fact, your code to declare it is probably overwriting it each time so try to avoid that (yes, I know, its not a best coding practice but its the way it works :-)

I assume you changed the radio button to input right? Perhaps you can send your robofile and we can help further.

Also what sensor are you using? Is it just a switch or something more complicated?

STeven.

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index