Hi Dave,

Thanks for the detailed info.  I had seen references to a pullup resistor while I was investigating the whole thing, but I didn't understand its purpose. 

> The normal way to connect a switch is to have a pullup resistor go
> from the input to your positive voltage (Vcc), and have the pushbutton
> go from the input to ground.
So if I understand correctly I have 2 lines (wires) coming off of GPIO 59.  One of those wires goes to my switch, which then goes to ground.  The other goes from the GPIO to the resistor and from the resistor to Vcc. 

                  |-------resistor--------Vcc
                  |
GPIO--------|--------switch------GRND


Since I am using the breakout-gs new version with Vcc as battery voltage (which I guess is 5v with the wall wart) is there anything different that I would need to do to step that voltage down to 3.3v or does the resistor do all that?

> As a general rule, you should insert a current limiting resistor. Is
> the LED you got a white or blue LED? They often have larger voltage
> drops.

The led I am using is blue.  I don't have the part number with me now but I can get its specs if that would be helpful.

Thanks for the help!

Chris
 


On 12/22/05, Dave Hylands <dhylands@gmail.com> wrote:
Hi Chris,

>  I ran a wire from GPIO 59 (lcd pads) and another from a ground pad.  In
> between I added a momentary NO pushbutton switch.  If I set the GPIO to
> output and set I could see when I pressed the button that the setting went
> to clear.  So that was fine, but it didn't really make sense to me to drive
> the GPIO as output when a button press seemed more like an input??  Then I
> played around with the sample char driver in the wiki and some other
> interrupt driver code I found in the mailing list.  In both of those it
> appears that the GPIOs are set as inputs so I thought I would give that a
> try.  Using either of those drivers I saw the interrupt being triggered all
> the time unless I pressed my switch, then it stopped.  I was able to edit
> that code and get it to work with the GPIO set as output and then the
> interrupt was triggered when I pressed the button.  Am I missing something
> here? Is setting the GPIO as output to trigger interrups like I am doing the
> wrong way to do this?

For inputs, you need something to drive the input all the time. The
interrupt in the sample driver is set to detect edges. When you press
the button you're setting the pin to ground (or logic low). When you
release the button, the input is now not connected to anything. CMOS
technology is very sensitive and a floating input will tend to follow
nearby signals (due to capacative coupling). So what's probably
happening is that the input line is following some other line which is
transitioning and thus creating edges.

The normal way to connect a switch is to have a pullup resistor go
from the input to your positive voltage (Vcc), and have the pushbutton
go from the input to ground. Any resistor value between 10k and 100k
should be fine for a pullup in this scenario (higher values draw less
current).

Then when the button is not pressed, the pullup will pull the input
upto Vcc (logic 1), and when you press the switch it will overcome the
pullup (almost zero ohms in the switch) and you'll get a logic low.

As a general rule, you don't want to connect a switch up to an ouput.
It's possible to damage things. If the output is driven high by the
processor and your switch connects the output to ground, then you're
effectively shorting Vcc and ground. The effect will depend on the
amount of resistance in the circuit.

>  That brings me to my led.  I got it from digikey because it said it was
> 3.4v and I knew the GPIOs could output 3.3v.  It is rated at 20 milli amps.
> If I hook this up to a GPIO and ground and drive the GPIO on output set I
> see the led come on, and when I clear the line it goes out.  Great!  Seems
> like it works to me, but I just wanted to make sure I wasn't doing something
> that was bad form.

As a general rule, you should insert a current limiting resistor. Is
the LED you got a white or blue LED? They often have larger voltage
drops.

--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&opclick
_______________________________________________
gumstix-users mailing list
gumstix-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gumstix-users