JSS3 Coding and Robotics
JSS3 Coding and Robotics
Week 1
Topic: Basic Electronic component of the Arduino board
Arduino is a microcontroller-based open-source electronic prototyping board which can be
programmed with an easy-to-use Arduino IDE.
USB connector:
This is a printer USB port used to load a program from the Arduino IDE onto the Arduino
board. The board can also be powered through this port.
Power port
The Arduino board can be powered through an AC-to-DC adapter or a battery. The power
source can be connected by plugging in a 2.1mm centre-positive plug into the power jack of
the board.
Microcontroller:
Atmega328P microcontroller
It is the most prominent black rectangular chip with 28 pins. Think of it as the brains of your
Arduino. The microcontroller used on the UNO board is Atmega328P by Atmel ( a major
microcontroller manufacturer). Atmega328P has the following components in it:
Flash memory of 32KB. The program loaded from Arduino IDE is stored here.
RAM of 2KB. This is a runtime memory.
CPU: It controls everything that goes on within the device. It fetches the program
instructions from flash memory and runs them with the help of RAM.
Electrically Erasable Programmable Read Only Memory (EEPROM) of 1KB.
This is a type of nonvolatile memory, and it keeps the data even after the device is
restarted and reset.
Atmega328P is pre-programmed with a bootloader. This allows you to directly upload a new
Arduino program into the device, without using any external hardware programmer, making
the Arduino UNO board easy to use.
Digital pins
You can find these pins labelled “Digital 0 to 13.” These pins can be used as either input or
output pins. When used as output, these pins act as a power supply source for the
components connected to them. When used as input pins, they read the signals from the
component connected to them.
When digital pins are used as output pins, they supply 40 milliamps of current at 5 volts,
which is more than enough to light an LED.
Week 2
Power is a specific notion, which is expressed in Watts (the symbol is W). Following is a
mathematical relationship between voltage, current, and power: P = V x I. Where, P is the
power in Watt, V the voltage in V, and I is the current in Ampères.
Resistors are defined by their electrical resistance expressed in Ohms (the symbol is Ω).
There is a direct mathematical relation between the voltage measured at the resistor sides,
current, and resistance known as Ohm's law: R = V / I where R is the electrical resistance in
Ohms, V the voltage in Volts, and I the current in Ampères.
Current can be compared to the hydraulic volume flow rate, which is the volumetric quantity
of flowing water over a time interval.
A flow rate doesn't require two points to be measured as a difference of pressure; we only
need one point of the circuit to make our measurement with equipment named an Ampere
meter.
In all of our applications, we'll deal with direct current (DC), which is different
from alternative current (AC).
Resistors are small components that slow down the flow of current. They are more resistive
than any piece of wire you can use; they generally dissipate as heat. They are two passive
terminal components and aren't polarized, which means you can wire them in both directions.
Resistors are defined by their electrical resistance expressed in Ohms (the symbol is Ω).
There is a direct mathematical relation between the voltage measured at the resistor sides,
current, and resistance known as Ohm's law:
R = V / I where R is the electrical resistance in Ohms, V the voltage in Volts, and I is the
current in Ampères.
For a constant value of voltage, if the resistance is high, the current is low and vice-versa. It
is important to have that in mind. On each resistor, there is a colour code showing the
resistance value.
There are many types of resistors. Some have a constant resistance, some others can provide
different resistance values depending on physical parameters such as temperature, or light
intensity for instance.
A potentiometer is a variable resistor. You move a slider or rotate a knob and the
resistance changes.
A capacitor (or condenser) is another type of component used very often. The direct
analogy is the rubber membrane put in the pipe: no water can pass through it, but water can
move by stretching it.
They are also passive two-terminal components but can be polarized. Usually, small
capacitors aren't.
We usually are saying that capacitors store potential energy by charging. Indeed, the rubber
membrane itself stores energy while you stretch it; try to release the stretched membrane,
and it will find its first position.
Capacitance is the value defining each capacitor. It is expressed in Farads (the symbol is F).
We'll stop here about capacitance calculations because it involves advanced mathematics
which isn't the purpose of this book. By the way, keep in mind the higher the capacitance the
more potential the capacitor can store.
A diode is again a two-terminal passive component but is polarized. It lets the current pass
through it only in one direction and stop it in the other. We'll see that even in the case of
direct current, it can help and make our circuits safer in some cases.
LEDs are a specific type of diode. While the current passes through them in the correct
direction, they glow. This is a nice property we'll use to check if our circuit is correctly closed
in a few minutes.
A transistor is the last item I'm describing here because it is a bit more complex, but we
cannot talk about electronics without quoting it.
Transistors are semiconductor devices that can amplify and switch electronic signals and
power, depending on how they are used. They are three-terminal components. This is the key
active component of almost all modern electronics around us. Microprocessors are made of
transistors and they can even contain more than 1 billion of them.
Transistors in the Arduino world are often used to drive high currents, which couldn't pass
through the Arduino board itself without burning it. In that case, we use them as analogue
switches. When we need them to close a circuit of high currents to drive a motor, for
instance, we just drive one of their three terminals with a 5 V coming from the Arduino and
the high current flows through it as if it had closed a circuit. In that case, it extends the
possibilities of the Arduino board, making us able to drive higher currents with our little piece
of hardware.
Week 3-4:
You can control a lot of things with an Arduino. Displays, LEDs, and other devices can easily
be hooked up to the I/O pins and controlled with a simple sketch.
But the output ports on an Arduino, or any microcontroller, are only designed to control logic-
level devices. Interfacing with anything that requires more than a logic-level signal is going to
require external components.
Alternating Current or AC differs from Direct Current (DC) in that it constantly changes
polarity, oscillating like a sine wave between positive and negative at a predetermined
frequency.
That frequency can vary depending upon where on the planet you are, in North America it is
60Hz while in most other parts of the world, it is 50Hz. Some industrial applications use
higher voltages and frequencies as high as 400Hz, but we won’t be considering these in our
experiments.
Project Work
Direct Current
Arduino can measure current using an analog input pin for Arduino UNO, there are 6 analog
input pins (A0-A5) and you can use one of the pins to measure DC. Arduino NANO has 8 pins
while Arduino MEGA has 16 input pins. The analog input pins will map input voltages between
0 and 5V into integer values between 0 and 1023 with a resolution of 4.9mV per unit (5.00V /
1024 units).
All sensors that are connected to analog input must be measured by voltage value. To
provide the current value, the sensor provides a voltage value that is related to the measured
current value.
The current sensor that is widely used for Arduino is the ACS712 Current Sensor Module. It
utilises the hall effect phenomenon in which voltage is produced from the movement of
current with the region's magnetic field. The voltage produced by the hall effect is directly
proportional to the applied current making it suitable to estimate the applied current from the
voltage sensed.
The sensor can measure current in 2 directions. A reverse current will not damage the sensor
but the voltage produced will be reduced. As we know, Arduino analog input only read
positive integer values. To measure 2 directions, the zero point should be at half the voltage
range (0 to 5V) which is 2.5V.
Project work
Week 5
Topic: L E D C i r c u i t C o n f i g u r a t i o n
When current flows through an LED in the positive direction, the voltage generated between
the anode and cathode is called the forward voltage (VF). The unit for voltage is volts (V).
This characteristic is the most important parameter when considering the actual LED lighting circuit.
The IF-VF characteristics will vary depending on the LED element material, size, and even
emitting colour. It will also vary depending on ambient temperature. In addition, there is a
characteristic value distribution specific to semiconductors, which is known as variability.
Variations in VF are not problematic when the LEDs operate under a constant current drive,
but for a constant voltage drive, it is necessary to take these changes and fluctuations into
account when designing.
LED Lighting Circuit
[In the case of a series lighting circuit]
When lighting up LEDs in series via constant voltage drive, the circuit typically includes a
resistor connected in series with the LEDs to control the current.
For this type of circuit, first, read the forward current IF and forward voltage VF of the lit LED
from the IF-VF characteristics.
The value of R (current control resistance) is determined through calculation by inputting
these values in the above equation.
For parallel connection with constant voltage drive, we recommend a circuit configuration that
utilizes a control resistor for each LED (which is arranged side by side in the above series
lighting circuit).
LED IF-VF characteristics will vary depending on the element material and emitting colour.
Furthermore, individual variations inherent to semiconductors exist even when the material
and emitting colour are the same.
As shown in the graph below, when the VF of LED ① and LED ② differ, controlling the
current with just one resistor makes it difficult to control the current flowing to each LED (IF1
and IF2).
Connecting a resistor to each LED allows the current flow to be set individually (IF1 and IF2),
enabling customized settings (i.e. to achieve the current matching, and suppress brightness
variations). In addition, applying a high voltage to the resistor, such as by increasing the
input voltage Vin, makes it possible to implement a design that takes into account variations.
Seven-segment LED
A seven-segment LED is a digital display module specialized to display numerical information.
Light-emitting diodes (LEDs) arranged in the shape of numbers offer an easily visible display.
They are sometimes called "seven-segment displays" or "seven-segment indicators."
Names of seven-segment LED parts
The parts of the seven-segment LED are as follows:
Light-emitting components (a–g): Segments (Seg)
Dot light-emitting component: Decimal point (DP)
A general name for the seven segments a–g: Digits (Dig).
Week 6
Topic: Breadboard Technology
A breadboard (sometimes called a plugblock) is used for building temporary circuits. It is useful
to designers because it allows components to be removed and replaced easily. It is useful to
the person who wants to build a circuit to demonstrate its action, and then reuse the
components in another circuit.
A breadboard consists of a plastic block holding a matrix of electrical sockets of a size suitable
for gripping thin connecting wires, component wires or the pins of transistors and integrated
circuits (ICs). The sockets are connected inside the board, usually in rows of five sockets. A
row of five connected sockets is filled in at the top right of the figure. The rows are 2.54 mm
apart and the sockets are spaced 2.54 mm apart in the rows, which is the correct spacing for
the pins of ICs and many other components.
A relay
Transistors
An inverter (a logic NOT-gate)
In the above circuit, you see a battery, a relay (in the red square) and a light bulb. To
understand the circuit you need to understand how a relay works.
When the relay coil has power, the switch will disconnect the power from the electromagnet
and connect the power to the light bulb instead so that it will light up.
But when the relay no longer has power, it will switch back and turn off the power from the
light bulb and give power back to the electromagnet again.
Week 9-11
Projects