when you start in electronics, whether with a Raspberry Pi or an Arduino, is quickly confronted with the calculation of the resistance. Whether to power an LED, polarize a transistor or other… there always need to make a calculation.
Manu, a loyal reader (and speaker) of the blog and the forum has put together this Pi-ramide that will remind you “on the go” the formulas you need.

click for information about the levels.

if some people think that the the ancient Egyptians knew electricity , it’s especially their knowledge in geometry that is found in the construction of the pyramids.

it is this solid that Manu has retained to create a memory aid for the use of the beginner electronics.

simple! Let’s take an example…

 we do simple, huh! A voltage U is applied to the terminals of a resistance. This tension is circulating a current I in the resistance. take this triangle that has the letters U, R and I U is the voltage at the terminals of the resistance (in volts) R is the resistance (in ohms) I is the intensity in the resistance (in amperes) you know resistance : R = 100 Ω and you have measured the current: 50 mA (0.050 A) you want to know the voltage at the terminals of the resistance? To find the form, place your thumb on the value that you are looking for (put thumb on U) there are only 2 letters from the bottom: R and I that are next to each other… the formula is U = R x I U = 100 x 0.050 = 5’re another application: you plug a LED on a Raspberry Pi GPIO output (you do have these ideas (, also 😉). When the tension of the GPIO passes at 3.3 volts (State 1) the LED lights. The voltage at its terminals and 1.6 volts (you measured it or better you read the doc – nan, there I dream 😀) and runs a current of 10 mA (0.010 has) LED (that too is in the doc (here, I insist 😉) which resistance must you use to make the LED light up normally, without turning into a lump of coal? []) well, as we’re looking for the value of R is on this letter to put the thumb… ‘Ve got us U at the top of the triangle and I down… That’s our formula. R = U / I you tell me I do not know U, the voltage present at the terminals of resistance! There are 3.3 volts on one of my paws and 1.6 volts on the other paw… So there is between the 2?  1.7 volts (do not tell me that you have pulled out the calculator 🙁) go we calculate R = 1.7 / 0.010 = 170 Ω heck in there is not in my Inbox! well put 180 Ω or 150 Ω and don’t tell anyone, it’ll work 🙂 in the same way, if you want to find, put your thumb on it and there? easy: I = U / R

## that’s all the same!

all the faces of the pyramid work the same way!

here one sees right P and R as well as 2 : P is the power in watts, R and I saw them just before.

then what must be the power of the resistance in the previous example? (this is to avoid it emit smoke signals before giving up the ghost)

I’m looking for P => I put the thumb on it there?  R x I 2

R told 180 Ω (this is the one I had in stock) and a current of 10 mA (0.010 A)-online

P = 180 x 0.01 x 0.01 = 0.018 watt

not worry one resistance 1/4 watt (250 mW) will do the trick as the dissipated power is only 18 mW. By security always plan at least double power to the power required.

and depending on the side you choose, you have one of these 4 options:

• P = U x I

• U = R x I

• P = R x I²

• P = U² / R

## and the square below the Pi-ramide?

Oh yes it’s true there is a square under the IP ramide! I almost forgot to tell you about 🙂

this concerns the bridge voltage divider:

an input voltage V in is applied to the bridge formed by 2 resistors, R1 and R2 divider. It allows to retrieve output V out , which is a part of the input voltage.

 come on we’re looking for V out so… we put the thumb on it! We multiply which is diagonal and divide by what remains! V out = (V in x R2) / (R1 + R2) you see right away that if R1 = R2… we divide the voltage by 2 (si vous ne me croyez pas, faites le calcul 🙂)

## example of a bridge divisor

well, this time we have a sensor (what you want 🙂) coming out either nothing (0 volt) or the 12 volt (level 1). Can’t send its output on a Raspberry Pi GPIO port. A GPIO supports 3.3 volts maximum.

we will use a bridge divisor to bring the voltage (12 volts) at 3.3 volts. I had in stock a resistance of 1KΩ which will do the trick for R2. Good, and what do I put for R1?

 heck on the square there is not R1… Just R1 + R2! Go we mask R1 + R2, that’s what we’re looking for (if we know R1 + R2 we know R1, no?) We multiply the diagonal and divide by what remains! (R1 + R2) = (v in x R2) / V out [19459078-](R1 + R2) = (12 x 1000) / 3.3 (R1 + R2) = 3636 Ω as R2 is 1KΩ 1000 Ω means that R1 must be 3636 – 1000 = 2636 Ω that I have not in stock: I 2, 7KΩ and 2, 2KΩ in my Inbox… Which one do I take?

Bin… to make sure we’re going to do the math the other way if you want to! take the bridge divisor seen previously with
R2 = R1 = 2.7 KΩ and 1KΩ
let you do the math… we find V out = 3.24 volts

then take 1KΩ = R2 and R1 = 2.2 KΩ
repeat the calculation and we find V out = 3.75 volts

then you take what you?

tadaaaa! I’ll R1 = 2.7 KΩ as 3.24 volts voltage is compatible with the GPIO ports because it is lower (very little) to 3.3 volts.

if I put the resistance of 2.2 KΩ, 3.75-Volt voltage will exceed the limit of 3.3 volts and my GPIO port risk to be destroyed, if I did not Bowl it is the CPU that will stop working… And a Raspberry Pi without microprocessor? Good to put in the trash (think recycling!)

the purists will tell you that it is wrong to lower tension with a bridge divisor to attack a GPIO. They recommend using a voltage converter, much safer. They are right! But the divisor Bridge works great if you are sure the voltage of the sensor.

hold the method which is to repeat the calculation “in the other direction. It ensures that the value found is consistent and my righteous calculations.

## an exercise to see if you have understood

to finish I propose an exercise to see if you yourself… (caution there may be a 🙂 trap… or not):
you have a deck divider consisting of 2 resistors R1 = 2.2 KΩ and R2 = 5.6 KΩ. Output voltage V out should be 5 volts… You send how to V in ?

take your time, do your math, check by repeating the calculation ‘backwards ‘. When you are certain that your result is good, open this PDF which offers you the solution 🙂

## method 1: cut-and – paste

Manu you makes it easy: he realized a pyramid model that you can cut. It is the one I used. There is even the flaps for the collage. Download this PDF file and print it out.

## method 2: Python

for those who would like to make their own Pi-ramide, Manu has written a Python program that calculates the different dimensions of the object:

`#!/usr/bin/python2.6 #-*-coding: utf-8-*-def Pythagoras (a, b, c): #= # displays the value of the sides of the triangle # a and b are the sides adjacent to the right angle # c is the side opposite the right angle] , the hypotenuse #= print "a = %s n b = %s n c = %s" % (str (a), (b) str, str (c)) #= # "a" is the value to search for #= type if (a) == type ('str'): = (c * 2 - b * 2) *.5 print "a = %f n" % a return has #= # "b" is the value to search for #= if type (b) == type ('str'): b = (c * 2 - a * 2) *.5 print "b = %f n" % b return b #= # 'c' is the value to search for 'hypotenuse' #= if type (c) == type ('str') : c = (a * 2 + b * 2) *.5 print "c = %f n" % c c# values on the sides of the pyramid return # cote_base = 10 # base square cote_base_sommet = 10 # stop to the top # length of the diagonal on the basis # print "nDiagonale base:" diagonale_base = Pythagoras (cote_base, cote_base, "?")# Center pyramid compared to the diagonal basis # print "nCentre of the pyramid on the diagonal:" centre_hauteur_diagonale = diagonale_base / 2 print centre_hauteur_diagonale # height of the pyramid # print "nHauteur of the pyramid:" hauteur_pyramide = Pythagoras ("?", centre_hauteur_diagonale, cote_base_sommet) # Center pyramid compared to one side of the surface of base # print "nCentre of the pyramid on the side" ":" centre_hauteur_cote = cote_base / 2 print centre_hauteur_cote # height on side angled pyramid # print "nhauteur on inclined face plane:" hauteur_face_incline = Pythagoras (centre_hauteur_cote, hauteur_pyramide, "?") `

with the Pi-ramide of ‘ all-in-card ‘ on your Workbench, finished the oversights of formula. It is a tool that you can leave without fear of short-circuit or wear of the batteries…

one day you no longer need. You will have integrated these formulas. But you will remember this IP ramide, who has helped you start 🙂

this article does not take into account present resistances in parallel on the entry or exit of the bridge… It’s another story 😉