Displaying how many switches are ON out of 10

Thread Starter

sg11

Joined May 14, 2015
8
Hi,

I want to show how many switches are ON in a LCD screen, I have 10 switches. I thought about using Full Adder or some logic gates based circuit but could not figure out how to add the input from switches. I am open to consider micro-controller option to do the work in case I cannot achieve it with some IC and normal circuit parts.

Please provide suggestions.

Thanks in advance!
Simi
 

AnalogKid

Joined Aug 1, 2013
11,056
What do you want the screen to show? Just the total number, 0 through 10? Ten boxes with check marks in them for the ones that are on? What are the switches for?

ak
 

MikeML

Joined Oct 2, 2009
5,444
10 resistors into an opamp summer that goes to the AD input of an Arduino with a LCD add-on shield. I could have it breadboarded with the code running in about 15min...
 

pwdixon

Joined Oct 11, 2012
488
10 resistors into an opamp summer that goes to the AD input of an Arduino with a LCD add-on shield. I could have it breadboarded with the code running in about 15min...
Or, leave out the summer and just use 10 resistors and 10 inputs?
 

ErnieM

Joined Apr 24, 2011
8,377
If you leave out the microcontroller what drives the LCD display?

If you go with an analog solution how do you convert the voltage back to something digital for the display?

With a full adder you need one adder for every two switches, 5 total. (Maybe less if you're smarter than I am). That still leaves the display to drive.

With a micro you need 10 pins for the switches, and whatever the LCD display needs. A typical alphanumeric display needs some 6 or 7 pins to drive it. Microchip makes literally hundreds of parts that can handle this, each by itself.
 
Last edited:

Thread Starter

sg11

Joined May 14, 2015
8
What do you want the screen to show? Just the total number, 0 through 10? Ten boxes with check marks in them for the ones that are on? What are the switches for?

ak
I want to show how many switches are on. For example: there are 10 switches on a board and if I turn on 2 out of them then LCD screen should show 2. If I turn off one of them it should 1, if I turn 3 more on it should show 4 in total.
 

Thread Starter

sg11

Joined May 14, 2015
8
10 resistors into an opamp summer that goes to the AD input of an Arduino with a LCD add-on shield. I could have it breadboarded with the code running in about 15min...
Thanks for the response. Can you please draw a circuit. Or please write the solution in more detail.
 

Thread Starter

sg11

Joined May 14, 2015
8
If you leave out the microcontroller what drives the LCD display?

If you go with an analog solution how do you convert the voltage back to something digital for the display?

With a full adder you need one adder for every two switches, 5 total. (Maybe less if you're smarter than I am). That still leaves the display to drive.

With a micro you need 10 pins for the switches, and whatever the LCD display needs. A typical alphanumeric display needs some 6 or 7 pins to drive it. Mocrichip makes literally hundreds of parts that can handle this, each by itself.
Thanks for looking into this. So If I am understanding correctly, you suggest that this can be done with microcontroller by the nature
I agree with blocco. It smells of school work. I gave you more than enough if it is...
It is not a school assignment but the idea of it brought a smile :)
The application is in my personal project, where there is a small part of electronics involved.
 

MrChips

Joined Oct 2, 2009
30,824
Do you really need a numeric output?
How about simply connecting one LED to each switch?
Or use a summing circuit to drive an LM3914 bar display?
 

Thread Starter

sg11

Joined May 14, 2015
8
Do you really need a numeric output?
How about simply connecting one LED to each switch?
Or use a summing circuit to drive an LM3914 bar display?
I really need numeric output because in case of LED's a user will need to count how many are on. Even the bar display will also have the same limitation.
If this is not possible without microcontroller then which microcontroller should I use?
 

MikeML

Joined Oct 2, 2009
5,444
Arduino, fastest learning curve if you have not worked with one before. There is a LCD module (shield) to go with it. It has a 10bit A/D converter. The program would be very simple after you include a library that lets you do formatted prints to the LCD.
What programming experience do you have?

Arduino

LCD screen for above

Not suggesting you buy from SparkFun, but it shows what is available.

The Arduino has 14 digital I/O pins, some of which are consumed talking to the LCD, so there are not quite enough to use one per switch. I would still use the opamp summer to make a voltage proportional to how many switches are pushed, and then go into the Arduino using the A/D converter to read that voltage. Converting the voltage to a number from 0 to 10 is trivial.
 

ebeowulf17

Joined Aug 12, 2014
3,307
+1 on the Arduino recommendation. It's ease of use and great support from places like Adafruit and Sparkfun got me playing with electronics and programming after 25+ years away from it.

You can even get around the pin limitation and skip the opamp summer if you want by using a display like this one which uses I2C communication, consuming only 2 pins.
 

Thread Starter

sg11

Joined May 14, 2015
8
Arduino, fastest learning curve if you have not worked with one before. There is a LCD module (shield) to go with it. It has a 10bit A/D converter. The program would be very simple after you include a library that lets you do formatted prints to the LCD.
What programming experience do you have?

Arduino

LCD screen for above

Not suggesting you buy from SparkFun, but it shows what is available.

The Arduino has 14 digital I/O pins, some of which are consumed talking to the LCD, so there are not quite enough to use one per switch. I would still use the opamp summer to make a voltage proportional to how many switches are pushed, and then go into the Arduino using the A/D converter to read that voltage. Converting the voltage to a number from 0 to 10 is trivial.
I have C, python and php programming experience. The LCD display you included looks really sophisticated, I wanted to build everything with in $10 excluding Arduino. If you think I am way off in my estimate then you can laugh but do let me know :)
 

Thread Starter

sg11

Joined May 14, 2015
8
+1 on the Arduino recommendation. It's ease of use and great support from places like Adafruit and Sparkfun got me playing with electronics and programming after 25+ years away from it.

You can even get around the pin limitation and skip the opamp summer if you want by using a display like this one which uses I2C communication, consuming only 2 pins.
Would like to keep cost to minimum and this LCD is very expensive. Thanks for suggesting an alternative though.
 

ErnieM

Joined Apr 24, 2011
8,377
How are your building skills? A huge advantage of solutions such as the Arduino is there is very little soldering and assembly work needed to get something to work. Basically all you do is plug the base into a "shield."

Now if you don't mind a bit of solder work you can have at this on your own, wiring everything up yourself. A two line by 8 character display can be had for under 4 bucks.

I like using DIP packages for prototypes even if my device only comes surface mount by using an adapter board, but you can get some nice controllers such as a PIC18F2331 (28 pin DIP) for $4.63 or a PIC18F4431 (40 pin DIP) for $5.26 . That's single piece prices out of DigiKey and they don't free ship, but they do have a ship option for under $3.25 for very small orders.

Might as well look for some prototype boards to build this on too. I like these with solid double sided holes to stick down things but others use other ways. Some wire and header pins are good to have on hand too. And get a bunch of 0.1uF caps too, you need that for bypassing the power lines.

Not quite under $10 but very close, and you'll have a few things on hand for the next job.
 

Thread Starter

sg11

Joined May 14, 2015
8
How are your building skills? A huge advantage of solutions such as the Arduino is there is very little soldering and assembly work needed to get something to work. Basically all you do is plug the base into a "shield."

Now if you don't mind a bit of solder work you can have at this on your own, wiring everything up yourself. A two line by 8 character display can be had for under 4 bucks.

I like using DIP packages for prototypes even if my device only comes surface mount by using an adapter board, but you can get some nice controllers such as a PIC18F2331 (28 pin DIP) for $4.63 or a PIC18F4431 (40 pin DIP) for $5.26 . That's single piece prices out of DigiKey and they don't free ship, but they do have a ship option for under $3.25 for very small orders.

Might as well look for some prototype boards to build this on too. I like these with solid double sided holes to stick down things but others use other ways. Some wire and header pins are good to have on hand too. And get a bunch of 0.1uF caps too, you need that for bypassing the power lines.

Not quite under $10 but very close, and you'll have a few things on hand for the next job.
Thank you so much for the details, I will check them out and will try to build it :)
 
Top