Arduino Handouts For Students

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

ARDUINO HANDOUTS AND

REVIEWER

ALAGA-18-18
[COMPANY NAME] [Company address]
Session 1: Getting Started with Arduino
Arduino is an open-source electronics platform based on easy-to-use hardware and software. It’s intended for anyone
making interactive projects.
Parts of Arduino

Barrel Jack Port(Power Port) – Arduino boards can be powered directly from the Ace mains power supply by connecting
it to the Barrel Jack

USB Port(Power USB) – Arduino board can be powered by using USB cable from your computer. All you need to do is
connect the USB cable to the USB connection.
It helps you to upload your code through USB cable.

Reset Button – Much like turning your computer off and on again, some problem with the Arduino can be solved by
pushing the reset button. This button will restart the code currently uploaded on your Arduino.

Digital Ports (Digital I/O) – The Arduino UNO board has 14 digital I/O pins (15) ( of which 6 provide PWM (Pulse Width
Modulation)) output. These pins can be configured to work as input digital pins to read logic values (0 or 1) or as digital
output pins to drive different modules like LEDs, relays, etc. The pins labeled “~” can be used generate PWM.

Analog In Ports – The Arduino Uno has six analog input pins A0 through A5. These pins can read the signal from an
analog sensor like the humidity sensor or temperature sensor and convert it into a digital value that can be read by the
microprocessor. The value of analog pins of is 0 - 1023

Power LED Indicator – This Led should light up when you plug your Arduino into a power source to indicate that your
board is powered up correctly. If this light does not turn on, then there is something wrong with the connection.

Microcontroller – The main IC (integrated circuit) on the Arduino is slightly different from board to board. The
microcontrollers are usually of the ATMEL Company. You must know what IC your board has before loading up a new
program from the Arduino IDE. This information is available on the top of the IC. For more details about the IC
construction and functions, you can refer to the data sheet.
Session 2: Introduction to Basic Electronic Components
Breadboard – is a construction based for prototyping of electronics.

LED (Light-Emitting Diode) – Semiconductor light source that emits light when current flows through it.

Resistor – to control the flow of current to other components. example. If too much current flows through an LED it is
destroyed. So a resistor is used to limit the current.

void
The void keyword is use only in function declarations. It indicates that the function is expected to return no information
to the function from which it was called.

setup()
The setup() function is called when your program starts. Use it to initialize your variables, pin modes, start using
libraries, etc. The setup function will only run once, after each powerup or reset of the Arduino board.

loop()
After creating a setup() function, which initializes and sets the initial values, the loop() function does precisely what its
name suggests, and loops consecutively, allowing your program to change and respond. Use it to actively control the
Arduino board.

pinMode(pin, mode)
Configures the specified pin to behave either as an input or an output.
Parameters
pin: the number of the pin whose mode you wish to set. (int)
mode: either INPUT or OUTPUT

digitalWrite(pin, value)
Sets a pin configured as OUTPUT to either a HIGH or a LOW state at the specified pin.
The digitalWrite() function is also used to set pullup resistor when a pin is configure as an INPUT
Parameter
pin: the pin number
value: HIGH or LOW

delay()
Pauses the program for the amount of time (in miliseconds) specified as parameter. (There are 1000 milliseconds in a
second.)

HIGH
The meaning of HIGH (in reference to a pin) is somewhat different depending on whether a pin is set to an INPUT or
OUTPUT. When a pin is configured as an INPUT with pinMode, and read with digitalRead, the microcontroller will report
HIGH if a voltage of 3 volts or more is present at the pin.
When a pin is configured to OUTPUT with pinMode, and set to HIGH with digitalWrite, the pin is at 5 volts. In this state it
can source current, e.g. light an LED that is connected through a series resistor to ground, or to another pin configured
as an output, and set to LOW.
LOW
The meaning of LOW also has a different meaning depending on whether a pin is set to INPUT or OUTPUT. When a pin is
configured as an INPUT with pinMode, and read with digitalRead, the microcontroller will report LOW if a voltage of 2
volts or less is present at the pin.
When a pin is configured to OUTPUT with pinMode, and set to LOW with digitalWrite, the pin is at 0 volts. In this state it
can sink current, i.e. light an LED that is connected through a series resistor to, +5 volts, or to another pin configured as
an output, and set to HIGH.
Program for LED and Resistor for Session 2
Session 3: Controlling Digital Device
Variable – is a way of naming and storing a value for later use by the program, such as data from an analog pin set to
input.
If Statement – test whether a certain condition has been reached, such as an input being above a certain number.

If – else Statement – allows a greater control over the flow of code than the basic if statement, by allowing multiple test
to be grouped together.

digitalRead(pin) – Reads the value from a specified pin pin, it will be either HIGH or LOW.
Parameters
pin: the number of the digital pin you want to read.
Program for Push button in Session 2
Session 4: Using Digital Sensor in Arduino

PIR motion sensor – works by constantly comparing the level of infrared radiation (IR) of the surrounding are, this allows
the sensor to detect motion, these sensor are commonly used for home automation, such as automated lightning
systems, and security systems.

Serial.begin(speed) – Sets the data rate in bits per second (baud) for serial data transmission. For communicating with
Serial Monitor. 9600 maximum baud rate speed for serial.
Link: https://www.arduino.cc/reference/en/language/functions/communication/serial/begin/

Serial.println(val) – Print date to the serial port as human-readable ASCII text followed by a carriage return character.
Link: https://www.arduino.cc/reference/en/language/functions/communication/serial/println/

Serial.print(val)- Prints data to the serial port as human-readable ASCI text. This command can take many forms. Number
are printed using an ASCII character for each digitl.
Link: https://www.arduino.cc/reference/en/language/functions/communication/serial/print/

Program for PIR in Session 4


Session 5: Using Digital Sensor in Arduino

Soil Moisture Sensor – is usually used to detect the humidity of the soil.

analogRead(pin)

Description
Reads the value from the specified analog pin. The Arduino board contains a 6 channel (8 channels on the Mini
and Nano),
10-bit analog to digital converter. This means that it will map input voltages between 0 and 5 volts into integer
values
between 0 and 1023. This yields a resolution between readings of: 5 volts / 1024 units or, .0049 volts (4.9 mV)
per unit.
It takes about 100 us (0.0001 s) to read an analog input, so the maximum reading rate is about 10,000 times a
second.

Parameters
pin: the number of the analog input pin to read from (0 to 5 on most boards, 0 to 7 on the Mini and Nano)

Returns
An integer value in the range of 0 to 1023.

Program for Soil Moisture Sensor in Session 5

You might also like