0% found this document useful (0 votes)
41 views

basic-electronics-for-arduino-makers

Uploaded by

ritchycynada1999
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

basic-electronics-for-arduino-makers

Uploaded by

ritchycynada1999
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Basic Electronics for Arduino Makers

These days you can do so much with an Arduino that you almost don’t need to know anything
about electronics! But there are a few basic things that, when you learn them, open you up to a
much bigger world of possibilities. In this short guide, you’ll learn:

• The basics of electricity so that you can understand how it works, instead of trying to
memorize formulas.
• How to choose resistor values for LEDs so you don’t have to rely on the calculations of
others.
• How to use transistors so that you can control things like relays, motors, fans, and LED
strips with your Arduino.
• How to use analog sensors so that you can start seeing what’s going on outside of your
Arduino too.

Copyright © 2024 by Ohmify AS


The Basics of Electricity
The basics of electricity is very simple:

Wires and components are always completely filled with something called charges. When these
charges move, you have current. To get these charges to move, you need voltage.

It’s the movement of these charges that is the current, not the charges themselves. Since the
wires are always completely filled with charges, it means that they must move at the same
speed both at the beginning and at the end of the wire.

That means the current flowing out from a voltage source (such as a battery), is the same as the
current flowing back in!

Many are surprised by this fact. And I often get the question “but how does a battery die if the
current is the same coming back in?”. The thing is that the battery doesn’t store current. Current
can’t be stored. It’s the battery’s ability to push charges around in the circuit to create current
that eventually drains out.

Resistance
The final concept to understand is resistance. Resistance in a circuit resists the current. The
more resistance a circuit has, the more voltage is needed to get the same current. You can think
of resistance as a tighter tube, making it harder for the charges to move.

Copyright © 2024 by Ohmify AS


Ohm’s Law
Voltage, Current, and Resistance affect each other. This relationship is called Ohm’s law.

Ohm’s law is basically just a simple formula that makes it easy to calculate voltage, current, and
resistance. You can use it to find what resistor value you need for an LED. Or to find out how
much power your circuit uses. And much more.

This is one of the few formulas in electronics that you’ll use on a regular basis.

V=R*I
• V is the symbol for voltage.
• I is the symbol for current.
• R is the symbol for resistance.

You can switch it around and get R = V/I or I = V/R. If you have two variables, you can calculate
the third. An easy way to find the formula for one specific variable is to use this triangle:

How to use it:

Use your hand to cover the letter you want to find. If one of the remaining letters is above the
other, it means dividing the top one by the bottom one. If they are next to each other, it means
multiplying one with the other.

V=I*R

Copyright © 2024 by Ohmify AS


R = V/I

I = V/R

Copyright © 2024 by Ohmify AS


How to Calculate Resistor Values for LEDs
When you're connecting an LED to an Arduino, choosing the correct resistor value is important
to ensure that you don't burn out the LED. The resistor limits the amount of current flowing
through the LED.

To calculate the resistance value for a LED, you need to know:

• the output pin’s voltage (usually 5V)


• the forward voltage of the LED (assume 2V if you don’t know)
• the current you want for your LED (5-10 mA is usually a good value)

Here’s the formula for calculating the minimum resistance value you need:

R = (VPIN – VLED) / ILED

Copyright © 2024 by Ohmify AS


Example:

You’re using an Arduino UNO with 5V pins and you want to light up an LED with a forward voltage
of 2.3V. You do not want to go above 10 mA for the LED.

VPIN: 5V

VLED: 2.3V

ILED: 0.01A

Plot this into the formula and you’ll get:

R = (5V – 2.3V) / 0.01A = 270 Ω


This means that if you use a resistor of 270 Ω, you’ll get 10 mA for your LED.

Remember, if you don't have the exact value of resistor, you can always use the nearest value
going up. It's better to use a slightly higher value of resistance than a lower one to avoid
damaging the LED.

Where did 10 mA and 2.3V come from?


The forward voltage of an LED is the voltage that the LED will have across itself when lit. For a
red LED, it’s usually around 2.3V. You can get this value from the datasheet of the LED (which
the people who sold you the LED should be able to provide). Or you can measure it by
connecting it in series with a 1000 Ω resistor and measuring the voltage across the LED.

10 mA is a common current value for LEDs that will make it light up, without damaging it. The
only way to find the maximum current that an LED can withstand is to check its datasheet.

Copyright © 2024 by Ohmify AS


How To Use Transistors with Arduino
An output pin from the Arduino UNO can only give you 5V and about 20 mA. If you want to
control something that needs more current and/or voltage, like a motor, you need to use a
transistor.

A transistor acts as a switch, allowing a small signal from the Arduino to control a larger voltage
and current needed to run the motor.

The two main transistor types are BJT and MOSFET.

If you need a lot of voltage or current, MOSFET is the best choice. If you only need a hundred
milliamps or so, then BJT will also work fine.

Each transistor type exists in an n-type and a p-type. The n-type is the most common one to use,
so that’s what you’ll see in this booklet.

The n-type of the BJT is called an NPN transistor.

The n-type of the MOSFET is called an nMOS transistor.

Copyright © 2024 by Ohmify AS


Arduino Transistor Circuit: BJT

In this example circuit, an Arduino control a motor using an NPN transistor (BJT).

The BJT needs a resistor (R1) in between the output pin and the base of the transistor to limit the
current flowing through the base. 1000 Ω is a good starting point for R1. You can learn how to
calculate it for your specific situation in this article.

Connect your load (ex your motor) between the plus and the collector of your transistor.

When you set the output pin HIGH, the transistor turns on and allows current to flow through it.
This means your motor turns on. When you set the output pin LOW, the transistor turns off and
no current can flow through it. This means your motor turns off.

The diode (D1) is there to protect the transistor from back-emf of the motor. It will work without,
but you’ll most likely damage your transistor after a short while.

Copyright © 2024 by Ohmify AS


Arduino Transistor Circuit: MOSFET

The MOSFET does not need a resistor in between the output pin and the gate of the transistor.
But it’s good to place a resistor from gate and down to ground, otherwise your transistor will be
left in an ON state if you turn off your Arduino when the transistor was on.

Connect your load (ex your motor) between the plus and the drain of your transistor.

When you set the output pin HIGH, the transistor turns on and allows current to flow through it.
This means your motor turns on. When you set the output pin LOW, the transistor turns off and
no current can flow through it. This means your motor turns off.

Copyright © 2024 by Ohmify AS


How To Connect Analog Sensors
Resistive sensors like photoresistors for measuring light and thermistors for measuring
temperature are easy to set up with Arduino. Just connect the sensor to one of the Arduino's
analog input pins and create a simple circuit that allows the Arduino to read the sensor's output
as a voltage.

A very common method is to use a voltage divider circuit:

The resistor value you choose will affect the sensitivity of your sensor. Often, resistors between
10k and 100k are used. But feel free to experiment to find the best value for your use case.

When reading the value from the Arduino pin, you’ll get a number between 0 and 1023. 0 means
0V and 1023 means 5V. With the following code, you’ll convert that number into the actual
voltage that’s on the pin:

void setup() {
Serial.begin(9600);
}

void loop() {
int sensorValue = analogRead(A0);
float voltage = sensorValue * (5.0 / 1023.0);
Serial.println(voltage);
delay(1000);
}

If you need to know the resistance value of your sensor, you can calculate it using this formula:
𝑉𝑠𝑢𝑝𝑝𝑙𝑦
𝑅𝑠𝑒𝑛𝑠𝑜𝑟 = 𝑅𝑓𝑖𝑥𝑒𝑑 × ( − 1)
𝑉𝑚𝑒𝑎𝑠𝑢𝑟𝑒𝑑

Copyright © 2024 by Ohmify AS


Here’s the Arduino code for this:
const int analogPin = A0; // Pin connected to the sensor
const float R_fixed = 10000.0; // Fixed resistor value
const float V_supply = 5.0; // Supply voltage in volts

void setup() {
Serial.begin(9600
}

void loop() {
int sensorValue = analogRead(analogPin);
float V_measured = (sensorValue * V_supply) / 1023.0;
float R_sensor = R_fixed * ((V_supply / V_measured) - 1.0);

// Print the calculated resistance to the Serial Monitor


Serial.print("Sensor Resistance: ");
Serial.print(R_sensor);
Serial.println(" ohms");

delay(1000);
}

Copyright © 2024 by Ohmify AS


Want To Learn More?
If you're new to electronics - or trying to get back into it - here are two ways I can help you learn
electronics:

1. Getting Started With Electronics is a short and beginner-friendly eBook I wrote to help
people get started. It contains clear and simple instructions to get started building
electronics. Perfect for complete beginners.

2. Our online classes at Ohmify is for those who want to learn skills like soldering, circuit
design, Arduino, and PCB design and more in order to confidently create electronic
gadgets and tools – and who are prepared to take action to make it happen.

Keep On Soldering!
Oyvind @ build-electronic-circuits.com

Copyright © 2024 by Ohmify AS

You might also like