Displaying how many switches are ON out of 10

Discussion in 'The Projects Forum' started by sg11, May 14, 2015.

  1. sg11

    Thread Starter New Member

    May 14, 2015
    8
    0
    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
     
  2. AnalogKid

    Distinguished Member

    Aug 1, 2013
    4,518
    1,247
    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
     
  3. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    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...
     
  4. pwdixon

    Member

    Oct 11, 2012
    488
    56
    Or, leave out the summer and just use 10 resistors and 10 inputs?
     
  5. ebeowulf17

    Active Member

    Aug 12, 2014
    678
    79
    Maybe replace Arduino with LM3916 for non-microcontroller solution?
     
  6. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    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: May 16, 2015
  7. sg11

    Thread Starter New Member

    May 14, 2015
    8
    0
    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.
     
  8. sg11

    Thread Starter New Member

    May 14, 2015
    8
    0
    Thanks for the response. Can you please draw a circuit. Or please write the solution in more detail.
     
  9. blocco a spirale

    AAC Fanatic!

    Jun 18, 2008
    1,438
    368
    What is the application for this circuit? It sounds like an assignment.
     
  10. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    I agree with blocco. It smells of school work. I gave you more than enough if it is...
     
  11. sg11

    Thread Starter New Member

    May 14, 2015
    8
    0
    Thanks for looking into this. So If I am understanding correctly, you suggest that this can be done with microcontroller by the nature
    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.
     
  12. MrChips

    Moderator

    Oct 2, 2009
    12,421
    3,357
    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?
     
  13. sg11

    Thread Starter New Member

    May 14, 2015
    8
    0
    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?
     
  14. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    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.
     
  15. ebeowulf17

    Active Member

    Aug 12, 2014
    678
    79
    +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.
     
  16. sg11

    Thread Starter New Member

    May 14, 2015
    8
    0
    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 :)
     
  17. sg11

    Thread Starter New Member

    May 14, 2015
    8
    0
    Would like to keep cost to minimum and this LCD is very expensive. Thanks for suggesting an alternative though.
     
  18. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    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.
     
    sg11 and Roderick Young like this.
  19. sg11

    Thread Starter New Member

    May 14, 2015
    8
    0
    Thank you so much for the details, I will check them out and will try to build it :)
     
  20. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    You dont have to spend a lot for Arduino stuff:

    Uno R3

    LCD
     
    sg11 likes this.
Loading...