View Single Post
  #8   Spotlight this post!  
Unread 12-02-2007, 23:36
steve d steve d is offline
Registered User
FRC #1277
 
Join Date: Jan 2007
Location: Groton, ma
Posts: 38
steve d is an unknown quantity at this point
Re: Limit Switches help

we have limit switches wire to the digital in/outs. The motor turns untill a certian pattern of switches open/clsed is reached, To make an integer from 4 digital i/os do this:
word = dig_in01<<3
word+= dig_in02<<2
word+= dig_in03<<1
word+= dig_in04

Say dig_01 & dig_03 were closed, making "0", the 4 bit word would be 0110 or 6.
Remember, inside the digital_in/outs are tied high, they read 1, you need to ground it to read 0.

Turn the motor until the number is the lift state you want. Think "state machine".