Learn Electronics with Arduino

Feb 25, 2017

What is Arduino?


Before we begin building projects with Arduino, it will be usueful to understand what Arduino is,  the various components on the Arduino Uno board, and different Arduino boards available.

Generally Arduino means both the Arduino board and Arduino software in the form of IDE.  The most common and the most recommended board for beginners is the Arduino Uno Rev3 board. Arduino Uno Rev3 board is a single board micro-controller. It provides an easy interface to the programmable micro-controller and the various input/output pins. The good thing about using the Uno as your first board is that if you do anything wrong you can easily replace the ATmega328P micro-controller.

The Fig. 1 shows the main components on the Arduino Uno R3 board.
Fig 1. Arduino Uno R3 with main components labelled
This board is based on Atmel's ATmega328P programmable micro-controller along with ATMega16U2 which is preloaded with Boot loader and programmed as a USB-to-serial converter.  It has 14 digital input/output pins of which 6 can be used as PWM outputs and 6 analog inputs. Each digital pin provides a maximum of 5V and a minimum of GND. The PWM pins in the Fig 1 is shown by ~ near the pin number. Note that Arduino board does not provide any analog output, however we can use the PWM output as analog output which we will visit later.  The locations of these pins on the board is shown in Fig 1 below.

It also has a USB-B port, a center positive power socket, 16 MHz crystal, ICSP headers for both micro-controllers, and a reset button. The board can also be powered through the USB instead of the power jack.

If you connect the power supply in reverse polarity (center negative) through the power socket, there are components on the board that will resist to sent the current in the opposite direction.  Note that just protection does not exists if you connect the power supply via the power pins and you may end up damaging your board.

Feb 18, 2017

Project 0: Push button controlled LED


Purpose

The LED should light up when the push button is pressed and when the push button is released the LED should turn off. As this is a basic project, we want to achieve it without the use of Arduino board.

Components that you need

  • 2 x AA battery with a battery holder
  • Breadboard
  • LED
  • Push button switch
  • 220Ω resistor
  • bunch of jump wires

Building the circuit

Fig 1 shows the schematics for the circuit. It has the 2 AA batteries, the 220Ω resistor, the LED and the switch connected in serial. The reason why we have the resistor is to limit the amount of current. An LED offers very little resistance, so if we directly connect the LED to the battery, when the switch is turned on close to infinite current will pass through it burning out the LED.
Fig 1.  Schematics Circuit Diagram
Fig 2. shows how it can be assembled on a breadboard. The +ve and the -ve terminals of the battery are connected to the bus lines. Through the bus lines, the +ve terminal is connected to the switch and then to the anode of the LED and the -ve terminal is connected to the 220Ω resistor and then to the cathode of the LED. If you require a refresher on how breadboard works, you might want to read the Component Overview: Breadboard.
Fig 2.  Breadboard circuit
This way when you press the switch the circuit is complete and the current will from anode of the LED to the cathode of the LED, lighting it up.

Which resistor to use?

According to the Ohm's law as long as we know the voltage and the current we should be able to calculate the resistance value.

$$R = \frac{(V_{supply} − V_{forward})}{I_{forward}}$$
If, like me, you have a generic LED and the component details will not be available to you.  In this case we will work with generalization.  Below are the typical forward voltage and the forward current values that we can work with.

LED color Forward Voltage Forward Current
Red LED 2V 15mA
Green LED 2.1V 20mA
Blue LED 3.2V 25mA
Yellow LED 3.2V 25mA
Table 1. LED color and their faverage orward voltage and currents

We also know the supply voltage is 3V.  So putting all the numbers in the equation, we get the minimum required resistance as 66.67Ω. If you do not have the exact resistor value you can put the next available resistor, which in my case was 220Ω.  The LED will not be lighted up with the maximum efficiency, but it will be lighted up with 220Ω.

What did we learn?

  1. Relationship between voltage, current and resistance.
  2. How components like resistors, LED and breadboard works.
  3. How to calculate the resistor value required in the circuit.

Feb 12, 2017

Component Overview: LED (Light Emitting Diode)


What is LED?

LED or Light Emitting Diode is an electronic component that emits light when current passes through it in one direction. It will not allow the current to pass through in the other direction.
Fig 1. Standard Green, Yellow, Red LED
If a current more than its threshold is applied to it in either direction, the LED will burn out.

How to identify the correct direction of the current flow.

LED has two leads, usually of different length,  The longer lead is called the anode (+ve) and the shorter leg is called cathode (-ve). On a circuit the LED should be assembled such that the current enters from the anode and exits through the cathode.

Another way to identify a standard LED is look the LED from the top. The anode is of the smaller width than the cathode.  If you look an LED from the side you can see an arrow in which the current can flow.
Fig. 2 From top to bottom: Top view, Side view and symbol for LED

Feb 11, 2017

Component Overview: Resistor


What is a resistor?

An electronic component that resists the flow of current is called a resistor.  Almost all components offer resistance. A copper wire has close to zero resistance while the resistance of the air is close to infinity.  Resistors are a common component of all electronic and electrical circuits. The most common resistor available is the axial lead resistor as shown in Fig 1.
Fig 1. 220 ohm resistor with 5% tolerance

How to know a resistor value?

Most electronic components use color coding to mark the value of the component. The resistor follow the same technique. Fig 1. shows a regular resistor.  Usually it has 4 bands of various colors which needs to be decoded to get the resistor values.  Though it is not a very efficient way, it works very well for electronic components has they are very small and printing the actual value on the component may be very small and unreadable causing confusion.

To decode the value of resistor, first get the value of each bands on the resistor using the reference table below.  For the resistor in Fig 1. the bonds from left to right are red, red, black and gold.  Looking up the values we get 2, 2, 0, 5 which would translate in 22 x 100 - 5%, which is 220Ω with 5% tolerance.

What is tolerance?  It means that the actual value of the resistor will be anywhere between 5% of the decoded value.  For the above resistor, it can be anywhere between 209 and 231.

For a 5 band resistor, the 4th band is the multiplier and the 5th band is the tolerance value
More precise the resistor value you need for your circuit, the less the tolerance value you should go for. Consequently the expensive the resistor will be.
Seeing the color on a small resistor can be difficult most of the times. Hence it is better to measure the resistance value using the multimeter before you put it in your circuit
Ring colorSignificant figuresMultiplierToleranceTemperature coefficient
NameCodeRALPercentLetterppm/KLetter
None±20%M
PinkPK3015×10−3[5]×0.001
SilverSR×10−2×0.01±10%K
GoldGD×10−1×0.1±5%J
BlackBK90050×100×1250U
BrownBN80031×101×10±1%F100S
RedRD30002×102×100±2%G50R
OrangeOG20033×103×100015P
YellowYE10214×104×10000±5%25Q
GreenGN60185×105×100000±0.5%D20Z
BlueBU50156×106×1000000±0.25%C10Z
VioletVT40057×107×10000000±0.1%B5M
GrayGY70008×108×100000000±0.05% ±10%A1K
WhiteWH10139×109×1000000000
Table 1. The standard color code per IEC 60062:2016


Feb 4, 2017

Component Overview: Breadboard


What is breadboard?

Breadboard is a construction base used for prototyping of electronics.  It looks like a rectangular plastic board with lots of holes on it.  The Fig 1 shows a breadboard from top.

Why is it called a breadboard?

In the early days, when people wanted to construct a prototype they would do so on a flat wooden board by driving nails into it and then wrapping wires around the nails to connect to the various components.  A flat wooden board that was most handy in those days was an actual bread board on which bread was sliced. As components become smaller and electronics become more popular people started improving their prototyping base.  In the 1970s, solderless protoying board was invented. As soldering was not required, this board could be easily reused and become popular. However the name stuck from the early days of electronics.

Internals of breadboard

The internal connections of breadboard are straight forward.  The green lines in Fig 1 shows the internal connections of a breadboard. It shows a half+ size breadboard.  
Fig 1. Breadboard internal connection
The set of 5 holes as show in the diagram above are connected with other. except the sets which make up the horizontal line. This set of 5 holes are called terminal strips. This is where all the components go in. The horizontal lines on the top and the bottom of the bread board are called bus lines and the whole horizontal line is connected.  These are usually used to power the components. All the holes take in the 24 AWG size wires.  These wires are called jump wires.