NOOB needs help connecting switches

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Oshack
 
Posts: 4
Joined: Tue May 22, 2018 8:31 am

NOOB needs help connecting switches

Post by Oshack »

Hi,

I have the mini sound board and am trying to trigger it with the fancy momentary switches that have LEDs in the switches in my vehicle. I have wired the switches to always be illuminated and have put 12 volt to 5 volt reducers in line of each switch. I have all grounds (switches and sound board) tied together, creating one ‘master ground’.

Any time I manually touch the trigger to the switches’ ‘hot’ wire, it triggers the sound I want. However, if I hard wire it to the switch as soon as I turn on the ignition the sound just keeps playing as though the switch is always hot. What am I doing wrong and how do I fix it?

This is how my switches are wired:
85EF7EFD-E5F0-4566-BB33-FB1AE9C2C2B8.jpeg
85EF7EFD-E5F0-4566-BB33-FB1AE9C2C2B8.jpeg (80.35 KiB) Viewed 227 times

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: NOOB needs help connecting switches

Post by adafruit_support_mike »

The labels on the switch pins have the following meanings:

- C: Common.. the other two pins connect to it at different times
- NC: Normally Closed.. this one is connected to Common when you don't press the switch
- NO: Normally Open.. this one connects to Common when you press the switch

The + and - are the positive and negative ends of the built-in LED.

To use the switch to trigger sounds on the FX Board, you have to connect the Common pin to GND and the Normally Open pin to the trigger pin on the FX Board. Pressing the switch connects the trigger pin to GND, which tells the FX Board to play that sound.

If you also want the switch to control the LED, you have to arrange things so closing the switch sends current through the LED.

We already know the Normally Open pin is what triggers the sound, so you have to connect the LED to that too. We already know the Common pin is connected to GND, so we have to connect the LED so it lights up when the Normally Open pin has a connection to GND.

That means you want to connect the negative end of the LED to the Normally Open pin, and you want to connect the positive end of the LED to a positive voltage.

The FX Board's trigger pin will sit at 3.3V when they aren't connected to GND, so that would be the best voltage to use at the positive end of the LED. You can also use 5V, but you might find red LEDs lighting up slightly even when the switch is open. The 1.7V difference between 3.3V and 5V is just enough to light a red LED.

User avatar
Oshack
 
Posts: 4
Joined: Tue May 22, 2018 8:31 am

Re: NOOB needs help connecting switches

Post by Oshack »

Thank you for the detailed reply! You are correct in that the extra 1.7v still triggers the sound board, so I’ve ordered some 12v to 3.3v ones.

User avatar
kenhylind
 
Posts: 7
Joined: Wed Sep 19, 2018 1:37 am

Re: NOOB needs help connecting switches

Post by kenhylind »

Hi Guys,
I'm also a noob, and also adding an LED switch with sound.
Can you explain this part a little more?

"and you want to connect the positive end of the LED to a positive voltage.

The FX Board's trigger pin will sit at 3.3V when they aren't connected to GND, so that would be the best voltage to use at the positive end of the LED."


Thanks!
Ken

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: NOOB needs help connecting switches

Post by adafruit_support_mike »

LEDs, and all other diodes, only allow current to flow through in one direction.

The details are kind of hairy, but I'll try to skim the high points in a way that makes sense:

Silicon's outer layer of electron orbitals can hold 8 electrons, but it only has 4, called its 'valence electrons'. In a silicon crystal, each atom shares one valence electron with each of the four neighbors around it.. that way each atom thinks it has 8 electrons in its outer shell half the time. If you put an atom with 3 or 5 valence electrons into the crystal, you get either an extra electron or an empty orbital where another electron can go. We make things like diodes by adding small amounts of such atoms (called 'dopants') at a normal concentration of about 1 dopant per million silicon atoms. A crystal doped to have extra electrons is called 'N-type silicon' and one doped to have empty orbitals is called 'P-type silicon'.

Phosphorus has 5 valence electrons, so it's an N-type dopant. Boron has 3 valence electrons, making it a P-type dopant.

If you put a piece of P-type silicon against a piece of N-type silicon, creating what's known as a 'PN-junction', the extra electrons in the N side will move into orbitals in the P-side. That makes the silicon crystal happy.. each silicon atom goes back to sharing one electron with each of its neighbors.. but it throws the dopant atoms out of whack. A phosphorus atom wants to have 5 valence electrons, and if it only has 4, that empty orbital has a positive electric charge. A boron atom trying to juggle 4 valence electrons instead of the 3 it wants has a negative electric charge.

Left to themselves, a phosphorus atom with an empty orbital and a boron atom with an extra electron would move toward each other until the electron could go back where it's wanted. The dopants in a silicon crystal can't move though, so the positive phosphorus and negative boron are locked in place as poles of an electric field.

Electrons move away from the negative side of an electric field and toward the positive side, so the built-in field pulls electrons back toward the N-layer. That makes the field weaker though, so there's nothing to stop the electrons from hopping back into empty orbitals in the P-layer. What we end up with is an electric field a few atoms wide, where the force pulling electrons back to the N-layer balances their tendency to hop into orbitals in the P-layer.

That space exists as kind of an electrical stalemate, with electrons not moving because they're pulled equally in both directions.. we call it the 'depletion region' because there are no electrons able to move. And since the electrons don't move, no current can flow through the depletion region.

Just to be clear on this point: the positive end of the depletion region's electric field lives in the N-layer, where the phosphorus wants its electrons back. The negative end of the field lives in the P-layer, where the boron has more electrons than it wants.

If we apply an external electric field pointing the same direction as the built-in field (negative end on the P-layer, positive end on the N-layer), it pulls the depletion region even wider. Electrons moving into the P-layer don't pass through to the N-layer, they just create more boron atoms with an extra electron in the P-layer. We call that 'reverse-biasing' the PN-junction.

If we apply an external electric field that opposes the built-in field (negative end on the N-layer, positive end on the P-layer), it makes the built-in field weaker, and the depletion region narrower. The external field can pull electrons in the P-layer away from the outer edge of the depletion region, and another electron from the N-layer can bubble through the depletion region to fill that empty orbital. Current does flow through the depletion region under those conditions, which we call 'forward-biasing' the PN-junction.

The amount of current that can flow through the depletion region is controlled by how much of the built-in field we cancel with the external one.

The component we call a 'diode' is just a PN junction with wires stuck to the P- and N-layers so we can get current to them. The forward bias necessary to make current flow from the P-layer to the N-layer is called the diode's 'forward voltage'.

LEDs are diodes with an extra twist.

When electrons from the N-layer hop into orbitals in the P-layer, they have to release some energy. The energy comes out as photons (light) whose wavelength is proportional to the amount of energy the electron had to dump. For normal silicon diodes, the wavelength is in the near-infrared region.

If we use different dopants, the electrons have to dump enough energy for the photons to have wavelengths in the visible light spectrum. The higher the forward voltage necessary to cancel the built-in field, the more energy the photons have, and the farther the the color advances from red to blue.


So...


LEDs only emit light if you connect power to them the right way: positive voltage on the P-layer, negative voltage on the N-layer. If you have a lit LED in a breadboard, pull it out, flip it around, and plug it back with the pins reversed, it won't light up again. The PN-junction inside it will be reverse-biased, blocking any current that tries to flow through.

User avatar
kenhylind
 
Posts: 7
Joined: Wed Sep 19, 2018 1:37 am

Re: NOOB needs help connecting switches

Post by kenhylind »

Holy cow.
Thanks, Mike! I appreciate this detailed response!

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”