View Single Post
  #6   Spotlight this post!  
Unread 02-03-2004, 17:09
jacob_dilles's Avatar
jacob_dilles jacob_dilles is offline
Registered User
AKA: theshadow
FRC #0620 (WarBots)
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Vienna, VA
Posts: 245
jacob_dilles will become famous soon enough
Send a message via AIM to jacob_dilles
Re: Digital In Question

when you set a pin to be an "input" in the initilzation code, it automaticly sets an internal pull up resistor. when the switch/rotor/encoder/aliean space ship is "off" as in OPEN the I/O reads a "1" on say "rc_dig_io01" or whatever the variable is. you then proceed to wire the switch to the pin and to ground. that way, when it is in the "on" i.e. "CLOSED" postion, the circut is shorted thrugh ground ( but its thrugh a 100 million billion ohm resistor so its not a problem ) and when you read it it calls it a "0"

so when your rotory switch, pic a ground pin, and solder that to the common. then for each "leg", solder it to inputs 1, 2, 3 etc ( actualy, id start at 7 if you dont have any, its an inturpt thing for future expandibity) so 7, 8, 9 etc. then to code it, you can either have a million
Code:
if a=0 and b=1 and c=1 and d=1 {do this}
if a=1 and b=0 and c=0 and d=1 {do this}
if a=0 and b=1 and c=0 and d=1 {do this}
if a=1 and b=0 and c=0 and d=1 {do this}
or you can have a switch statement. or NESTED switch statements.

or even better, you could have a lookup table! lol have fun with the code tho...
__________________
--------------------------
"You're not a real programmer until all your sentences end with semicolons;"