Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
61 views11 pages

Name ID Course Section Term Paper: Arshman Shahbaz F2019376001 DLD Y1 Arduino

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 11

Name Arshman Shahbaz

ID F2019376001
Course DLD
Section Y1
Term Paper Arduino
Arduino

Introduction
It is astonishing how Arduino gained popularity in a squat amount of time. It
was introduced as a student project since then it became favourite in both
hobbyists and professionals. Arduino is an open-source platform (similar to
other such as GitHub etc) for building electronic projects in which you can
receive and send digital and analogue data.
One of the biggest features of Arduino is that it uses Microcontroller. A
microcontroller is a computer chip with minimal processing power and that
often is designed for automatic controlling some type of external device
meaning you can get the most out of just one device instead of having lots of
component squeezed into chips. Moreover, Arduino is an open-source
hardware to public meaning allowing anyone to use it free of charge and use it
in their own projects, they can even modify it. However, after using or
modifying it you should refrain using the name “Arduino” for industrial
purpose.
Atmel ATmega AVR family of microcontroller chips is used to power the
Arduino. It is a complete microcontroller system built into a single chip which
allows developer to use minimal external sockets. Atmel ATmega AVR is an 8-
bit computer which contains several features: -
 Flash memory for storing program code statements.
 Static random-access memory (SRAM) for storing program data.
 Erasable electronic programmable read-only memory (EEPROM) for
storing long-term data.
 Digital input and output ports.
 Analog-to-digital converter (ADC) for converting analog input signals to
digital format.

Types of Arduinos
There are many types of Arduinos, there family is huge. These are the
following Arduinos: -
 Arduino Uno
 Arduino Due
 Arduino Leonardo
 Arduino Mega
 Arduino Micro
 Arduino Esplora
 Arduino Yun
 Arduino Ethernet
 LilyPad Arduino

Arduino Due
It uses a more powerful 32-bit ARM Cortex-M3 CPU instead of the standard
ATmega328 microcontroller. Therefore, more processing power than standard
Arduino UNO. It consists of 54 digital I/O interfaces, 12 PWM outputs, 12
analog inputs, and 4 serial Universal Asynchronous Receiver/Transmitter
(UART) interfaces. It also provides considerably more memory, with 96KB of
SRAM for data storage, and 512KB of flash memory for program code storage.

Arduino Leonardo
It uses ATmega32u4 microcontroller, which provides 20 digital I/O interfaces, 7
PWM outputs, and 12 analog inputs. The Arduino Leonardo has the same
header layout as the Uno, with additional header sockets for the extra
interfaces.

Arduino Mega
It uses an ATmega2560 microcontroller, which provides 54 digital I/O
interfaces, 15 PWM outputs, 16 analog inputs, and 4 UART serial ports. You can
use all the standard Arduino shields with the Mega unit. It provides many
interfaces however, it’s costly.
Arduino Micro
It is a small size Arduino which provides basic capabilities. It uses the same
ATmega32u4 microcontroller as the Lenardo, which provides 20 digital I/O
interfaces, 7 PWM outputs, and 12 analog inputs. One of the advantages it has
is that it’s small enough to fit into any electronic project.

Arduino Esplora
It is mainly used to create open source game controllers such as Analog
joystick, LED lights, Switches for up, down, left, and right etc. It uses the
ATmega 32u4 microcontroller.

Arduino Yun
It is a combination of two microcontrollers which are ATMega32u4
microcontroller with an Atheros microprocessor and they run on Linux
operating system. Moreover, it has built-in Ethernet and Wi-Fi ports for
external communication.

Arduino Ethernet
It is basically an Arduino UNO with a wired Ethernet interface in one unit.

LilyPad Arduino
It is designed for the textile arts world, embedding a microcontroller within
textiles. It’s small, thin perfect for sewing any type of fabric.

Arduino UNO
Arduino UNO is very useful and it contains all the basic structure to use. You
can make 15 simple projects with Arduino UNO kit as a beginner. However, we
will only focus on Arduino UNO. Check out the figure below to understand the
layout of Arduino UNO.
Fig 1
To understand the layout of Arduino UNO, take a look at Fig 1. The Arduino
UNO can be powered from a USB cable coming from your computer or a wall
power supply that is terminated in a barrel jack. The USB connection is labelled
(1) and barrel jack is labelled (2). The Arduino consist of different type of pins
of which each has a separate function from other. Label (3) is for Ground, there
are several more on the microcontroller from which any of them will work.
Label (4)(3) is used for voltage. Label 6 are analogue pins, what they can do is
read analogue signals and convert them into digital signals. Label (7) are the
digital pins, they can be used for both digital input and output. Label (8) if you
notice there are some pins with the symbol ~ this can be used as digital pins
but they are also used for Pulse-Width Modulation (PWM). Label (9) is used as
analogue reference. Label (10) is a reset button. What it does is reset pins to
ground and restart code from null. Label (11) It’s a LED indicator the feature of
it is whenever you connect an Arduino with a power-source this should light up
if it doesn’t then that indicates something is wrong. Label (12) shows TX and
RX, TX is used for transmit and RX is used for receiving. Label (13) is Integrated
Circuit which is the brain of Arduino. Label (14) is Voltage Regulator to control
the amount of voltage to let into Arduino.
Accessories you will need for your basic projects
 A USB A-B cable
 An external power source
 A breadboard
 Resistors
 Variable resistors
 Switches
 Wires
 Sensors
 Motors

Arduinos language
Just working on physical Arduino hardware is not enough for your project to be
successfully completed. Beside that you will need a program/code to instruct
your ATmega microcontroller to what to do. ATmega microcontroller consist of
main three parts: -
 The CPU
 Memory
 The input/output (I/O) interface
You instruct the microcontroller what to do by writing programs. Machine
code is used directly used by microcontroller in form of 1 and 0s to process
data. But its not easy to use by human so developers used assembly language
which is easier than machine language. Assembly language consist of 282
instructions but they were very hard to remember by humans. Luck for us they
even developed an easier high-level language called C which is easier to type
code in and instruct the microcontroller on what to do. You can directly
download Arduino software which comes with IDE and libraries which you can
download from official Arduinos website.

Sample example for beginners: -


int counter = 0;
int pin = 13;

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(pin, OUTPUT);
digitalWrite(pin, LOW);
}

void loop() {
// put your main code here, to run repeatedly:
counter = counter + 1;
digitalWrite(pin, HIGH);
Serial.print("Blink #");
Serial.println(counter);
delay(1000);
digitalWrite(pin, LOW);
delay(1000);
}
This is a basic Arduino code. You can write it and verify it, Arduino software is
really friendly for user to understand The Arduino IDE uses brown to indicate
functions used in the sketch code, and uses blue to indicate text strings
contained in the sketch code. However, if you have any error it will pinpoint
the line the error is occurring to so that’s another point. After writing your
code verify it, after verifying you can upload it on your Arduino port and your
project should start working if hardware is setup properly.

C-language
C is the language for Arduino software through which you give instruction to
microcontroller. I will guide you to the basic of C language so you have an idea
on how C works, I know you are a master at Arduino Dr Tahir!
You can declare a variable in two types to represent memory location for
storing data.
 Declare the variable for use in the sketch.
 Assign a data value to the variable.
When you declare a variably compiler stores memory for it when you run the
program in a specific location.

Declaring variable
Syntax of declaring variable: -
datatype variablename;

The datatype defines what kind of data your variable will store and makes
storage according to that. C language has a strict rule for data types meaning if
you declare a variable with one data type you can’t store value in it for another
data type. This is due to one main reason when you declare a data type
compiler fixes a memory for only that data type hence no other data type can
fix in it. Example of data types are int, float, double, string etc.
When declaring a variable there are some rules which you must follow which
are: -
 The variable name must contain only letters, numbers, underscores, or
the dollar sign.
 The variable name must start with a letter.
 The variable name is case sensitive.
 There is no limit to the variable name length.
One of the advantages we have is that we can declare variable with meaningful
word since there is no length limit in declaring a variable name. Every
statement in C should end with semi-colon “;”, This is to know that one
statement ends and other starts.
We have other features in C language to modify how compiler handles variable
in sketch. One of them is constant, what constant does it that the variables
assign with constant property won’t change no matter what the cost.

Variable scope
There are two ways you can define variables scope.
 Local variables
 Global variables
If you declare a variable locally, what happens is that those variables can be
accessed in only that scope which can be any set of blocks. They won’t be
accessible outside that scope. However, if a variable is declared globally than it
can be accesses anywhere through out the program. It’s common practice to
declare a variable globally so that you can access it easily in your set and loop
function.

Operators
Declaring a variable and assigning it a value is not enough for your program to
work. Sometimes you want to perform mathematical task to achieve your
objective such as how fast light should blink, how fast motor should run etc.
Arduino contains standard math operators to perform task which are: -
 Arithmetic Operators (+, -, *, /, %, post-increment, pre-increment, post-
decrement, pre-decrement).
 Relational Operators (==, !=, >, <, >= & <=) Logical Operators (&&, ||
and !)
 Bitwise Operators (&, |, ^, ~, >> and <<).
 Assignment Operators (=, +=, -=, *=, etc)
 Other Operators (conditional, comma, sizeof, address, redirecton).
All these operators have different features which are very helpful for
performing different tasks.
Arduino has another feature install in C called functions. Functions are
somewhat of black box. you send values to function, function performs some
operations and produce output. One other feature Arduino provides is ability
to output data in an external device, this makes it easy to monitor what’s going
on in our Arduino sketches.
We have other work time features which are: -
 delay(): Pauses the sketch for x milliseconds.
 delayMicroseconds( ): Pauses the sketch for x microseconds.
 micros(): Returns the number of microseconds since the Arduino was
reset.
 millis(): Returns the number of milliseconds since the Arduino was reset
These features are very helpful, we don’t have to struggle online to find
libraries them since they are pre-installed on Arduino software.

To conclude I would say Arduino is the best program so far as a hardware and
software for students, professional to use. It is cheap, easy to use and can
cover all projects. You can easily start-up with no background and build all the
way up. Above were the basic concept of Arduino hardware and software,
after learning you can make up many projects to build.
References
 Sams Teach Yourself Arduino™ Programming in 24 Hours
Link
 https://learn.sparkfun.com/tutorials/what-is-an-arduino/all

You might also like