Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Count and track buttons... Help and Ideas

Status
Not open for further replies.

JaXz

New Member
Been trying to figure out away to do this for the past few days and I finally give in and I'm just going to ask for help. The cleanest way I can think to do this is with a PIC but I don't know enough to do it that way nor the equipment.

Here is what I'm trying to do.

Total of 10 buttons. 2 LED's

(RED) (GREEN)

[01] [02] [03] [04] [05] [06] [07] [08] [09] [10]

So if I push (in order)....

[01] (GREEN) blinks once
[02] (GREEN) blinks once
[03] (GREEN) blinks once
[04] (GREEN) blinks once
[05] (GREEN) blinks once
[06] (GREEN) blinks once
[07] (GREEN) blinks once
[08] (GREEN) blinks once
[09] (GREEN) blinks once
[10] (GREEN) blinks once

Now the part that has me stumped.

After pushing [10] and (GREEN) blinking once, I then push [05], (RED) should blink 4 times

After [05] blinks (RED) 4 times, I then push [07], (GREEN) should blink 2 times

[10] to [05] (RED) blinks 5 times
[05] to [07] (GREEN) blinks 2 times
[01] to [06] (GREEN) blinks 5 times
[06] to [01] (RED) blinks 5 times

Sounds so simple but I just cant figure out wrap my head around the easiest solution. If using a PIC is the only way to do this any suggestions on a cheap programmer and an example ?

Thanks.
 
Last edited by a moderator:
ClydeCrashKop said:
That sure looks to me like it requires a program.
Definitely start here https://www.electro-tech-online.com/threads/pic-newcomers-please-read-upd-0xd1.15035/
Nigel’s first few tutorials will cover that. I am happy with the Fox-Delta programmer from Nigel’s page for $20.00 but other people are happy with Inch Worm and others. Check out the micro-controllers section of this forum.

Thanks ClydeCrashKop, Link is very helpful. Guessing if I go that way I'd use a PIC16F883 I guess and the PICkit 2. PICkit 2 seemed to be a "all I need" programmer, plus USB is nice. Also after looking at a few examples, ASM doesn't seem as complex as I thought. But again I'd hoped to not have to go this way.

3v0 said:
What happens if the buttons are pushed out of order ?

[01] will always be the base. So if i push [05] (GREEN) will blink 4 times. Being [5] is 4 from 1...
[01] to [05] (GREEN) 4 times.
[05] being the last button pushed, pushing [02].. (RED) would blink 3 times.

Hope that helps explain this alittle more. I might add that if you can't already tell that I don't know a lot about circuitry but I'm a quick learner.

How I first tried to get this to work was to use a 555 timer and a 4510. Just not really sure how to tell it where to start from and stop at.

Thanks.
 
Last edited by a moderator:
Help with parts list..

I've had alot of fun learning about PIC's. Started off diving into ASM and its not all that bad but switched to BASIC being its just easier to read for me at this point.

The only thing I'm having trouble with at this point is what resistors, caps, opto's, ect I need. Mouser catalog is somewhat overwhelming with all the choices. I'm going to be buying a PicKit2 dev and use that PIC that it comes with but the final product will most likely be a lower pin count PIC. Want to order everything I need in one go. Also wouldn't mind on ordering extra commonly used parts. So if you want to rattle off some parts you use alot I'd appreciate it.

This is the project I'm working on, its basically a keypad that triggers 2 switches on another device. Originally I used 2 relays but then learned that opto's will do the same thing with less voltage and money. Not 100% sure if thats the right way to do it but it seems to do the job. In Proteus that is.

In the picture I'm using a PIC16F913
PORTA are all set to inputs.
PORTB, PORTC are set to outputs.

Have yet to make up my mind on where I'll be getting the power from to run all this. For now it will be just a 9v battery but will most likely end up using USB to power it. Now if I do use USB to power this do I need to still use a 7805 to make sure everything is safe ?

**broken link removed**
 
Last edited:
JaXz said:
Have yet to make up my mind on where I'll be getting the power from to run all this. For now it will be just a 9v battery but will most likely end up using USB to power it. Now if I do use USB to power this do I need to still use a 7805 to make sure everything is safe ?

You can't use a 7805 with only 5V feeding it, you need more than 8V.

From USB you could power it directly.
 
Nigel Goodwin said:
You can't use a 7805 with only 5V feeding it, you need more than 8V.

From USB you could power it directly.

Guess what I was getting at was I would still need to protect the PIC if USB was used. And or protect the host.
 
You could add some RFI suppression and a 100-500ma fuse to the 5V line from the USB, but otherwise the PIC should be fine. Also bypass the PICs power rails with a 0.1uF cap.
You should add some resistors to limit the current to the Opto's LEDs. What are you planning on driving with the Opto's transistors?
I also notice that the keypad common line is connected to Vdd. It would be easier to connect the common line to Vss and use the PICs internal pullups. Otherwise you'll need pulldowns on PortA if you leave the keypad common line connected to Vdd.
 
Last edited:
kchriste said:
You could add some RFI suppression and a 100-500ma fuse to the 5V line from the USB, but otherwise the PIC should be fine. Also bypass the PICs power rails with a 0.1uF cap.
You should add some resistors to limit the current to the Opto's LEDs. What are you planning on driving with the Opto's transistors?
I also notice that the keypad common line is connected to Vdd. It would be easier to connect the common line to Vss and use the PICs internal pullups. Otherwise you'll need pulldowns on PortA if you leave the keypad common line connected to Vdd.

Sorry for the late reply.

kchriste, thank you for pushing me to try to use the pullup's again. The first time I tried to get them to work I just didn't have the settings right. They sure are handy.

For the OpTo's, I will be using 470R resistors on them.

Finally about the EMI/RFI suppression and the fuse for using USB to power everything. I'm abit unsure what suppressor to use. Suggestions ? The fuse I'm guessing a 500ma PTC (MF-R050) ? Mainly just want to protect the source. After all a PIC and afew other components are much cheaper than a motherboard or other USB host.


I placed an order this passed Friday for parts and my Pickit 2 Dev and it should be hear Tuesday. While waiting I started messing around with this keypad to see if I could get to use less I/O pins. Correct me if I'm wrong but doing a A/D 1 wire keypad seems abit flaky.

So what I'm doing is basicly a binary keypad. 4 I/O gets me 14 buttons, 8 I/O gets me 91 buttons.. I don't need that many but again I'm just killing time and learning. How I started togo about this was to find a 4PST pushbutton switch but the only ones I could find were huge and or $20 USD each. I then started messing around with diode combinations and finally managed to get everything working. The only thing is its using 29 1N4148 diodes. (302 if I did the 8 I/O setup :p) Which at $0.02 USD each it isn't bad but to me it seems abit messy and I'm sure there is a cleaner way to isolate each button.

**broken link removed**

JaXz
 
I'm abit unsure what suppressor to use. Suggestions ?
Ferrite bead on the +5V line should be good enough.
4 I/O gets me 14 buttons, 8 I/O gets me 91 buttons.
You should be able to get 15 and 255 with 4 IO and 8 IO respectively. 0x00 reserved for no button pushed. Yea, it's a lot of diodes. If you have 8 IO available it would be better to arrange the keys in a 4 x 4 matrix and eliminate 29 diodes.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top