techbro2
Posts: 5
Joined: Tue Nov 29, 2022 8:53 pm

Connect multiple toggle switches to a raspberry pi

Tue Nov 29, 2022 9:13 pm

Hi everyone,

I haven't bought a rasbperry pi yet, nor the toggle switches.

I'm trying to connect 7 or 8 toggle switches (SPST) to a raspberry pi, all of which could be read in individually to amount to 128 to 256 different combinations.

Photos will be stored on either a micro SD card or USB and based on the combination, a picture will be displayed on a HDMI connected screen.

My questions are the following:
- Can I do this with a Raspberry Pi 1 Model A+?
- Do I need to look for anything specific when buying toggle switches?
- What other materials do I need to connect the toggle switches? / Can I do it without a board and have them all connected through wires?

Anything would help. I genuenly don't know what I'm doing.

Thanks everyone!

ame
Posts: 6400
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Connect multiple toggle switches to a raspberry pi

Tue Nov 29, 2022 10:47 pm

Fundamentally, yes. We can fill in the details later.
Hmm. What can I put here?

wildfire
Posts: 1182
Joined: Sat Sep 03, 2016 10:39 am
Location: Dundee, Scotland

Re: Connect multiple toggle switches to a raspberry pi

Wed Nov 30, 2022 9:18 am

techbro2 wrote:
Tue Nov 29, 2022 9:13 pm

I haven't bought a rasbperry pi yet....
...
...Can I do this with a Raspberry Pi 1 Model A+?
What ame said, but is there any particular reason you want to use such an old model?
E8 85 A2 40 C9 40 81 94 40 81 95 40 89 84 89 96 A3
Still NF Shirls

PiGraham
Posts: 5169
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Connect multiple toggle switches to a raspberry pi

Wed Nov 30, 2022 9:36 am

Reasons to go with an A+ that I can think of are you already have one (not the case here) or size, power consumption and cost, but I think Pi Zero is better choice on all those fronts.

It could be worth looking at rotary BCD switches as a simpler way to select big numbers from few inputs.
Maybe something like this
https://uk.rs-online.com/web/p/pushwhee ... 4b92a59cf7

Two of those to 8 gpio for 0 to 99 with two switches.
Add another for higher range.
I think you could multiplex these with one output per switch and four inputs to read all switches. May need some diodes as well.
So 11 gpio for 3 BCD switches giving up to 999 values.
Unless you really like using binary.
Last edited by PiGraham on Wed Nov 30, 2022 9:55 am, edited 1 time in total.

PiGraham
Posts: 5169
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Connect multiple toggle switches to a raspberry pi

Wed Nov 30, 2022 9:53 am

Another approach could be to display the election value on a display and have a few setting buttons. One button to select the digit and another to increment the digit could be sufficient. This would work especially well if you mainly want to increment the value. Default to LSD and just press one increment button to progress all images.
You could quickly access any photo from 1000 with no more than 3 x 9 button pushes.
Add a third button to cerement selected digit and get max 3 x 5 pushes

If you overlay the selection number on the HDMI you don't need a separate display for selection. Just show the ID briefly onscreen as it changes.

techbro2
Posts: 5
Joined: Tue Nov 29, 2022 8:53 pm

Re: Connect multiple toggle switches to a raspberry pi

Wed Nov 30, 2022 4:44 pm

wildfire wrote:
Wed Nov 30, 2022 9:18 am
techbro2 wrote:
Tue Nov 29, 2022 9:13 pm

I haven't bought a rasbperry pi yet....
...
...Can I do this with a Raspberry Pi 1 Model A+?
What ame said, but is there any particular reason you want to use such an old model?
Hi, no particular reason. I just wanted something that had input/output pins that would allow me to connect 7-8 toggle switches, an SD or micro SD card, USB drive and HDMI cord for the display. That's all I need. Would you reccomend a different model?

techbro2
Posts: 5
Joined: Tue Nov 29, 2022 8:53 pm

Re: Connect multiple toggle switches to a raspberry pi

Wed Nov 30, 2022 4:48 pm

PiGraham wrote:
Wed Nov 30, 2022 9:36 am
Reasons to go with an A+ that I can think of are you already have one (not the case here) or size, power consumption and cost, but I think Pi Zero is better choice on all those fronts.

It could be worth looking at rotary BCD switches as a simpler way to select big numbers from few inputs.
Maybe something like this
https://uk.rs-online.com/web/p/pushwhee ... 4b92a59cf7

Two of those to 8 gpio for 0 to 99 with two switches.
Add another for higher range.
I think you could multiplex these with one output per switch and four inputs to read all switches. May need some diodes as well.
So 11 gpio for 3 BCD switches giving up to 999 values.
Unless you really like using binary.
Thanks for the suggestions. I'm attached to the idea of toggle switches as I'm trying to make almost an art installation. I'm going for the toggle switch experience

techbro2
Posts: 5
Joined: Tue Nov 29, 2022 8:53 pm

Re: Connect multiple toggle switches to a raspberry pi

Wed Nov 30, 2022 4:50 pm

PiGraham wrote:
Wed Nov 30, 2022 9:53 am
Another approach could be to display the election value on a display and have a few setting buttons. One button to select the digit and another to increment the digit could be sufficient. This would work especially well if you mainly want to increment the value. Default to LSD and just press one increment button to progress all images.
You could quickly access any photo from 1000 with no more than 3 x 9 button pushes.
Add a third button to cerement selected digit and get max 3 x 5 pushes

If you overlay the selection number on the HDMI you don't need a separate display for selection. Just show the ID briefly onscreen as it changes.
Hi. Thanks for the reply. I would like to connect a diplay that would display a photo not just an ID. As far as the input. I'm attached to the toggle switch concept as part of the experience. Is this doable with a raspberry pi?

techbro2
Posts: 5
Joined: Tue Nov 29, 2022 8:53 pm

Re: Connect multiple toggle switches to a raspberry pi

Wed Nov 30, 2022 4:53 pm

ame wrote:
Tue Nov 29, 2022 10:47 pm
Fundamentally, yes. We can fill in the details later.
Hi ame. Thanks for the reply.
- Anything specific I'd need to look for when it comes to toggle switches?
- How do they connect to the raspberry pi (I'd like to avoid using a breadboard) for individually parsed input?

Thanks!

wildfire
Posts: 1182
Joined: Sat Sep 03, 2016 10:39 am
Location: Dundee, Scotland

Re: Connect multiple toggle switches to a raspberry pi

Wed Nov 30, 2022 5:14 pm

techbro2 wrote:
Wed Nov 30, 2022 4:44 pm
Hi, no particular reason. I just wanted something that had input/output pins that would allow me to connect 7-8 toggle switches, an SD or micro SD card, USB drive and HDMI cord for the display. That's all I need. Would you reccomend a different model?
Any model Pi can do what you want, but if you may in the future repurpose it for another project then look at the 4 series. The zero series will require a hub if you want keyboard/mouse & USB drive connected simultaneously.

Just be aware of the chip crisis and the difficulty of obtaining a Pi.
E8 85 A2 40 C9 40 81 94 40 81 95 40 89 84 89 96 A3
Still NF Shirls

ame
Posts: 6400
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Connect multiple toggle switches to a raspberry pi

Wed Nov 30, 2022 8:46 pm

techbro2 wrote:
Wed Nov 30, 2022 4:53 pm
ame wrote:
Tue Nov 29, 2022 10:47 pm
Fundamentally, yes. We can fill in the details later.
Hi ame. Thanks for the reply.
- Anything specific I'd need to look for when it comes to toggle switches?
- How do they connect to the raspberry pi (I'd like to avoid using a breadboard) for individually parsed input?

Thanks!
Nope. Any toggle switch will do. Pick something you like the look of.

Next, get some DuPont connectors. You will need 9 pieces of wire for your 8 switches, with female DuPonts on one end. Connect all the centre pins of the switches together then connect a DuPont wire to that, which will plug into GND on the Pi. Next, connect the other 8 DuPont wires to the switch outputs and plug them into 8 GPIO pins on the Pi (doesn't matter which ones, but choose 8 pins that aren't used for other functions).

In your code, configure the 8 GPIO pins as inputs with pull-ups turned on. Done!

If you want to avoid soldering you can choose toggle switches with screw terminals.
Hmm. What can I put here?

PiGraham
Posts: 5169
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Connect multiple toggle switches to a raspberry pi

Thu Dec 01, 2022 8:59 am

techbro2 wrote:
Wed Nov 30, 2022 4:50 pm
PiGraham wrote:
Wed Nov 30, 2022 9:53 am
Another approach could be to display the election value on a display and have a few setting buttons. One button to select the digit and another to increment the digit could be sufficient. This would work especially well if you mainly want to increment the value. Default to LSD and just press one increment button to progress all images.
You could quickly access any photo from 1000 with no more than 3 x 9 button pushes.
Add a third button to cerement selected digit and get max 3 x 5 pushes

If you overlay the selection number on the HDMI you don't need a separate display for selection. Just show the ID briefly onscreen as it changes.
Hi. Thanks for the reply. I would like to connect a diplay that would display a photo not just an ID. As far as the input. I'm attached to the toggle switch concept as part of the experience. Is this doable with a raspberry pi?
The point is you can show a photo and other info. That info can be shown temporarily, maybe fade in & fade out in seconds.

It will probably be useful to confirm the ID of the photo.

You can just have binary on toggle switches, of course. The switch state is an info display of a sort.

Return to “Beginners”