Multiple Inputs on one pin?
adamgoldminer
Posts: 6
Hello again,
I need to take inputs on a single BS1 I/O pin from four push-button switches (simple on/off) at a time.· Is there a way to do this?
In my brain I could take the four switches and create a binary number 0 through 15 (could I·use a DAC for this?)·and pass this binary digit to the IC through the one input pin.· It's the process of creating the binary number and passing it to the pin that is beyond me at this point.
There has to be some way to do it.· I just don't know if its practical or if it would just be cheaper to purchase a BS2 so I can have the extra pins.
Regards,
Adam
I need to take inputs on a single BS1 I/O pin from four push-button switches (simple on/off) at a time.· Is there a way to do this?
In my brain I could take the four switches and create a binary number 0 through 15 (could I·use a DAC for this?)·and pass this binary digit to the IC through the one input pin.· It's the process of creating the binary number and passing it to the pin that is beyond me at this point.
There has to be some way to do it.· I just don't know if its practical or if it would just be cheaper to purchase a BS2 so I can have the extra pins.
Regards,
Adam
Comments
Jonathan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
Any button is as simple as connecting all the switches to the same input pin.· If the pin changes state, a button was pressed, but you'll have no way of knowing which button.
If you need to know which button, the the·POT command with distinct resistances would work, as suggested above.
yes, it'll take more than one pin to operate, but you gain 8 inputs.
4 for your buttons [noparse][[/noparse]2 if you matrix them] leaving 4 [noparse][[/noparse]6]others.
you'll need 3 pins from the stamp [noparse][[/noparse]data, clock & latch] so you'll have to move 2 of your current inputs to the shift register.
or use a PCF8574 I2C it will only take 2 pins from the Stamp and they can be shared with other I2C chips.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Smile ... It increases your face value!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
Post Edited (metron9) : 1/30/2009 6:28:45 AM GMT
I like the idea, and it seems the simplest solution. Desy I DO need to know WHICH pins are pressed.
Would that method allow me to tell if two buttons or depressed at the same time? Which is actually the most that could be pressed because the switches are double throw rocker switches.
Regards,
Adam
Yeah, it should be able to tell if two buttons are pressed at the same time. You may have to play with the resistor values. Set up the POT circuit, then debug values while playing with resistor values.
Jonathan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
Thanks for the help! I'll let you know how it goes.
Adam
Unless you can reuse them you will "save" one pin!
Is it "economical"?
Cheers
Vaclav
The output: Since I did a 3 time read of the pulsin to debouncec the button I had the debug output the error so you could see when that part of the code was working.
The circuit is the Astable Operation half way down the page here http://www.uoguelph.ca/~antoon/gadgets/555/555.html
The two resistors R6 and R7 are 1meg each The cap C1·is .1 not .01
This should give high pulse above 132mS and returns a 0 when no button is pushed
No button pushed will also be the case if the pulsin is out of a range set up by the lookdown code.
The buttons basically put a resistor in parallel with the 1 meg resistor between pins 6 and 7
Button 1 uses a 100k· R1
Button 2 uses 1 meg·· R2
Button 3 uses 2meg··· R3
Button 4 uses 3meg·· R4
Buttons are wired in series so that button 1 puts 100k in parallel with the 1meg on pins 6 and 7
Buttons 2,3 and 4 add 1,2 or 3meg in series with the 100k
This gives you 91k, 523k 756k and 859k for resistance between pins 6 and 7 on the 555 timer
That changes the frequency by decreasing the resistance that charges the capacitor, the cap charges faster.
Another way using a faster frequency perhaps would be to use the count command instead of the pulsin.
Diptrace schematic attached as well.
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
Post Edited (metron9) : 2/1/2009 3:22:04 AM GMT
Here are a couple of things I did several years ago:
Use the PULSIN command to read either the upper and lower pulse width to determine a resistor value with the method below.
This method allows you to multiplex two analog signals (or fixed resistor values on a switch) into one input to the Stamp.
webpages.charter.net/schwabelove/BasicStamp/vco.gif
Another method that can be derived from reading a keypad which uses a similar principal already mentioned...
webpages.charter.net/schwabelove/BasicStamp/3x5KeyPad.gif
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
A wealth of ideas for me to try.
Jonathan's POT method still seems simplest. Also going to use this method to read a temperature from a thermistor.
Regards,
Adam