Log in

View Full Version : How to connect the touch sensor?


DemonYawgmoth
09-02-2006, 15:51
We want to use one of the touch sensors that came in the sensor bag this year, and we cant seem to find anything online as to how to connect the touch sensor to the robot controller and such. Where would the wires connect on the RC? Would it plug into a digital input or analog input. I'm guessing analog, but im not sure? Thanks in advance guys.

Alan Anderson
09-02-2006, 16:07
Do you mean microswitch?
http://home.att.net/~wzmicro/images/sw4a.JPG
The "common" connection goes to ground, and either the "normally open" or "normally closed" connection goes to a digital input on the RC. You'll read its value as 1 when the switch is open, and 0 when the switch is closed.

DemonYawgmoth
09-02-2006, 16:34
maybe im doing something incorrectly, but if i test it with if (rc_dig_in01 == 0) and then do some other stuff, would that work? also, how would we print stuff with printf()? we used it 2 years ago but i forgot how to get it to work. Also, i forgot the proper procedure for connecting the RC or OI to the computer to actually get these printf values. Thanks.

Chriszuma
13-02-2006, 00:29
Yes, that should work, as long as the stuff you want it to do is enclosed in {braces}. The printf command is very simple.


printf( "The digital in is reading %d", (int)rc_dig_in01 );

When you download the code with IFI Loader, it should automatically bring up a terminal window that dissplays the printf outputs. (you can also click 'terminal window' in the menu to bring it up).