## MagPi 46 electronics

nickweb
Posts: 10
Joined: Tue Jan 22, 2013 11:14 pm
Location: Glasgow, Scotland
Contact: Website

### MagPi 46 electronics

Hi.

Anyone fancy explaining in a ELI5 way about why certain circuits need a resistor for buttons? (Page 28 - hasn't mentioned why at all).

Also, the voltage divider on page 30 - how does that work?

I was hoping the electronics bit would be a beginners guide - the diagrams are just plug and play without really explaining the theory behind it which is what I thought it was.

Cheers!
Thanks,

Nick

http://www.nick-web.co.uk/ee

Burngate
Posts: 6012
Joined: Thu Sep 29, 2011 4:34 pm
Contact: Website

### Re: MagPi 46 electronics

nickweb wrote:... about why certain circuits need a resistor for buttons? (Page 28 - hasn't mentioned why at all).
The short answer is that they don't.

The longer answer is what happens when you do something wrong by mistake, such as making the GPIO an output, and driving it (in this case) high while pushing the button.
Without the resistor, a large, uncontrolled current will flow, destroying the GPIO, which is bad.
With the resistor, nothing much happens, which is good.

Now you may think doing three wrong things together is unlikely, but more unlikely things happen every day. People win on the lottery, and cars crash on empty roads.
Why take the risk?
Also, the voltage divider on page 30 - how does that work?
As far as I can see, the distance sensor outputs a 5v pulse, but the Pi can't handle anything above 3v3, so that voltage divider drops the 5v to somewhere around 3v3

As an input, a GPIO has almost infinite resistance, so we can ignore that.
So we have a 510 ohm resistor and a 1k resistor in series.
The same current has to flow through both, and to do so the voltage across each has to be in proportion to their resistances.
(Does a current in a resistor cause the voltage, or does the voltage cause the current to flow?)
5v is across the two together, with 3.3v across the 1k resistor, and 1.7v across the 510 one. Ohm's law gives 3.3mA through each.
The GPIO sees only the 3.3v and is happy.
I was hoping the electronics bit would be a beginners guide - the diagrams are just plug and play without really explaining the theory behind it which is what I thought it was.
Unfortunately, a magazine such as the MagPi hasn't the space to go too deeply into things.
Yes, I'd like to see more detail, but not at the expense of other things.

Douglas6
Posts: 4766
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

### Re: MagPi 46 electronics

Also, current limiting resistors and voltage dividers have been covered ad nauseum. You can't expect every magazine article to repeat the essentials.