# Why does my switch need to be wired in this fashion?

Today was my first foray into electronics since high school, in the form of some simple Raspberry Pi experiments. I managed to get a circuit working where a switch controlled an LED with a potentiometer to control the brightness of the LED.

However, I am confused by the wiring of the switch. Firstly, here's a photo of my amazing work:

NOTE: the black lead on the potentiometer is not connected to anything (hard to tell in the photo). Also, I realised afterwards that I could have just inserted the potentiometer into the breadboard rather than soldering wires to it. Noob mistake (one of many).

Here's an attempt at a schematic (also probably wrong because I don't know what I'm doing):

simulate this circuit – Schematic created using CircuitLab

As you can see, I used a PiFace, which comes with the four switches located at the left and towards the bottom of the photo. It is the wiring of this switch that befuddles me. Since each switch has two terminals, I was expecting one terminal to act as an input and the other as an output. That is, I just feed my circuit through those two terminals and job done. But that didn't work.

I managed to find this image online:

This is what prompted me to guess the configuration below, which works. However, I don't understand why it works. Nor do I understand why there are two terminals for each switch if only one seems to be used. I suspect the clue is embedded within the text in the above image:

The four switches, numbered S1 to S4 are connected in parallel to the first four (0-3) inputs

However, I do not understand what this means. Perhaps a practical example of how I would use each terminal and an explanation of why the grounding is necessary would help my understanding.

• Your text contains some misconceptions, and it is not clear to me what exactly you are asking. Also: put a fixed resistor in series with your LED, not a potentiometer. And I would take 330 Ohm or even 1 KOhm. – Wouter van Ooijen Jan 4 '14 at 10:46
• @Wouter van Ooijen: I actually wanted to put in a fixed resistor, but my LEDs had no information about voltage/amperage, so I couldn't calculate the required ohms. Therefore, the potentiometer was just to allow me to control the current (and it works). Please enlighten me on my misconceptions. My primary question is "why can't I just wire the switch through its two terminals?" – me-- Jan 4 '14 at 11:00
• I realized that I could have just inserted the potentiometer into the breadboard rather than soldering wires to it Not if you want to keep your breadboards in a good state. The pot pins are quite thick and will loosen the contacts of the breadboard so it's a good idea to solder pins or wires, you can just use shorted ones. – alexan_e Jan 4 '14 at 11:14
• @alexan_e: ah, ok. Glad I didn't, then. – me-- Jan 4 '14 at 11:17
• "Why can't I just wire the switch through its two terminals?" You can, but "through" is a strange term to use in this context. Can you show what you did (how you wired your switch), what the effect was, and what you had expected? – Wouter van Ooijen Jan 4 '14 at 12:11

For the grounding it's easy. Basically a switch can have not 2 but 3 state. Basically

• High when pressed
• Undefined when unpressed and not grounded
• Low when unpressed and ground

simulate this circuit – Schematic created using CircuitLab

Grounding it will allow you to make sure the output low, without that it's a short circuit. So basically you'll use a pull-up or pull-down resistor for that.

They are connected in parallel means they are not connected one after each other but side to side. Example

simulate this circuit

So from what I read in your question, the switch sound like a "master switch" who can act on both of the 3 other switch. If pressed, it's like all the switch are pressed. But hard to tell without precise schematics.

The eight input pins detect a connection to ground (provided as the ninth pin). The four switches are connected in parallel to the first four input pins. The inputs are pulled up to 5V. This can be turned off so that the inputs float.

From this I surmise the following

simulate this circuit – Schematic created using CircuitLab

Read the data sheet before you start connecting to something. Your assumption that because there are nine terminals and four switches that 'each switch has two terminals' is unfounded.

The 9 terminals are 8 input channels and ground. As the text you quoted says, the switches are connected between the first four channels and ground, so the connection in your photo agrees with the schematic.