View Single Post
  #1   Spotlight this post!  
Unread 15-02-2010, 22:37
nekng's Avatar
nekng nekng is offline
Former 1836 Captain
AKA: Nate
FRC #1836 (MilkenKnights)
Team Role: Alumni
 
Join Date: Aug 2006
Rookie Year: 2007
Location: Los Angeles
Posts: 43
nekng is on a distinguished road
Another Switch Help Thread

Hi all,

I can't seem to figure this out. From what I understand, if I use a switch to bridge the signal and ground of one of the GPIO channels on the Digital Sidecar, then when the switch is closed I ought to get a reading of 0 and when it is open I ought to get a reading of 1. As far as I'm aware, the DSC has an internal resistor and I do not need an additional one. And also, as far as I'm aware, the following code should work:

DigitalInput* digi10= new DigitalInput(4,10);
if (digi10->Get())
printf("Pin 10: TRUE\n");
else if (!digi10->Get())
printf("Pin 10: FALSE\n");

So why is digi10->Get() always false no matter what the switch position is?

Also, before I tried to get a simple switch to work, I was attempting to use the photoswitch to work (the one provided in the 2006 KOP). Both the receiver and source require 12v which I supply from the power distribution board. The green/white wires are each a signal, one is NC and one NO. I tried plugging one of these into a GPIO port but that didn't work...The photoswitch itself is working though--it has a red light on the receiver that turns on when the beam is unbroken.

Any suggestions?
__________________