Ok i have seen a ton of ASM to make keypads for 4x4 and 3x4. My question is simpler. How can i use 1 pin to get a possible of only 3 results? Like 1x3.
I want it simple so if i need 3 switches why not use 3 diodes and 3 pull-ups?. I will be using 3 push buttons.
I wanted to know 2 things really and i know im a pain in the as* but heh i get confused learning to fast. (btw everything i see correct i save it as a PDF so i can keep a copy and not bother more lol)
Ok to the questions:
1. How would i wire this up ? (using a 18F1320 or similar)
2. How would i code it.
I know it feels like im asking for the complete info and not trying to learn but thats not true. I dont even own a programmer or chip. I did order a Junebug which is on its way. So i just want to be ready to start programming and creating some cool stuff.
Every post i read study and ask if i dont understand only to ensure that i will eventually
For some reason I can not upload an attachment. Connection closed by remote server
String 4 1K resistors in series. Attach one terminal of each switch to a junction common to 2 resistors. Attach one end resistor to gnd and the other to +5. Tie all the unused switch terminals together and then to an analog input pin. Use a weak pullup on the pin say 20K.
When all the switches are open you read 5V. When one closes the voltage is fixed by the resistor network. Do an ADC to figure out which switch is closed.
EDIT:
I have provided a solution to use multiple keys on a single input. Another would be to use a keyboard encoder and a serial input stream.
Better to use a PIC with enough pins so you can stay with digital inputs, use a tradition matrix where you scan row and column.
It would go a long way, both towards gaining knowledge and getting help, if you at least made a significant effort towards some preliminary design work. I, for one, am certainly not going to design a circuit for you, but if you make a positive effort, I'll be more than happy to guide you in the right direction. I can't speak for anyone else here, but that's my position.
There we go just made some time to do this but 2 issues didnt find the right PIC18F1320(1220) is in same fam so i assume same pinout. Also Could not find normal switches so used some wierd ones closest to normal
How would i program this to identify different presses? Like what exactly do i compare? and to what?
Not quite. You have VDD shorted to ground so I take it one should ignore the bad label. Each resistor that is switched in forms half of a voltage divider. That should work. But the generated voltages could be further apart.
This is what I was thinking of. The resistors act as a voltage divider with several taps. The voltages
will be aprox 5V all open, (2/3)5V, (1/3)5V, and 0V. Ohms law ... Not too sure what the best value would be for the 100K all open pullup. Big is better so long as it is not so weak that it does not work.
The resistors do not have to be 1K, just as long as they are the same size the voltages will work out the same. The higher the value the less current it will draw.
You need to read up on ADC conversion. Good time to get cozy with the data sheet and the header/device/include file.
Not bad, except as noted you have VDD connected to ground--you don't want to do that. What you have for your keys is a set of switched voltage dividers. Now, look at the values. Use Ohm's law and plug in your VDD voltage to determine what voltage the input at AN0 sees for each keypress. Are those good values?
Well, close, but your resistors are in parallel.
What 3v0 means is that you want a voltage divider, where each switch will give a different output voltage, which you can then read with an analog pin.
Yours will work, but you won't have much variation in voltage between the switches. It would work better if you used 1k, 1k5, 2k, and 2k5 instead of 100, 150....
What is the purpose of the 20k series resistor in your second schematic? Remember that the four 1k resistors in series already form a voltage divider network. Think it through. Do you need that 20 k resistor?
String 4 1K resistors in series. Attach one terminal of each switch to a junction common to 2 resistors. Attach one end resistor to gnd and the other to +5. Tie all the unused switch terminals together and then to an analog input pin. Use a weak pullup on the pin say 20K.
Also when all the switches are open the input to the analog pin will be floating/undefined (not driven) tristated..
You need a pull up or pull down to take care of that.
Yes but you set it up as a current limiting resistor.
See the schematic I added to my XXXX second post. And I am not sure what value would be best. At least 10K. I would try the 100K if it works.
Sort of. A pullup resistor is used to maintain a small, stable voltage on an input pin. If you left it off, your circuit MIGHT work correctly, but the pin's voltage may fluctuate, causing unwanted false inputs.
Sort of. A pullup resistor is used to maintain a small, stable voltage on an input pin. If you left it off, your circuit MIGHT work correctly, but the pin's voltage may fluctuate, causing unwanted false inputs.
ok cool. So there is no definite way to calculate the divided voltages right? Like i would have to place resistors and manually check each one to determine drop ?
All i know in ohms law is how to get 1 value from 2 others. I don't know how to subtract like 100k ohms from 5v to determine the drop on the resistor.
It's simple. Consider a 20 kOhm resistor in series with a 5 kOhm resistor, with 10 V applied across them. You want to determine the voltage at the point between them. First thing you do is calculate the current through the resistors:
I = V / R
I = 10 / (15 k + 5 k)
I = .5 mA
Now that you know that, you can calculate the voltage drop across each resistor:
V = I x R
V1 = .5 mA x 15 k
V1 = 7.5 V
V2 = .5 mA x 5 k
V2 = 2.5 V
Reality check: the two voltages should sum to the total supply voltage. 7.5 + 2.5 = 10. If you have more than two resistors, you can just extend this process. Now, work out your voltage drops.