SlideShare a Scribd company logo
7
ARDUINO PROGRAMMING -GLOSSARY
(C) MELabs (Mobile Embedded Labs Pvt.Ltd)
●
Sketch – Program that runs on the board
●
Pin – Input or Output connected to something – Eg: Output to an LED input to an
Switch
●
Digital – 1 (high) or 0 (Low) -ON/OFF
●
Analog – Range 0-255 (Led brightness)
●
Arduino IDE – Comes with C/C++ lib named as Wiring
●
Programs are written in C & C++ but only having two funtcions -
Setup() - Called once at the start of program, works as initialiser
Loop() - Called repeatedly until the board is powered-off
Most read
12
If --- else
MELabs (Mobile Embedded Labs Pvt.Ltd)
The if statement checks for a condition and executes the proceeding statement or set
of statements if the condition is 'true'.
Syntax
if (condition)
{
//statement(s)
}
Parameters
condition: a boolean expression i.e., can be true or false
Most read
15
For Statement -example
(C) MELabs (Mobile Embedded Labs Pvt.Ltd)
// Dim an LED using a PWM pin
int PWMpin = 10; // LED in series with 470 ohm resistor on pin 10
void setup()
{
// no setup needed
}
void loop()
{
for (int i=0; i <= 255; i++) {
analogWrite(PWMpin, i);
//Writes an analog value (PWM wave) to a pin. Can be used to light a LED at varying brightnesses or
drive a motor at various speeds
delay(10);
}
}
Most read
•
Introduction to Arduino
•
UNO Overview
•
Programming Basics
•
Arduino Libraires
l
Siji Sunny
siji@melabs.in
Arduino Programming
(For Beginners)
WHAT IS ARDUINO
(C) MELabs (Mobile Embedded Labs Pvt.Ltd)

The Arduino project started in 2003 as a program for students at the Interaction Design
Institute Ivrea in Ivrea, Italy

Open Source Hardware and Software Platform

single-board microcontroller

Allows to building digital devices and interactive objects that can sense and control
objects in the physical world.
DEVELOPMENT ENVIRONMENT
(C) MELabs (Mobile Embedded Labs Pvt.Ltd)

The Arduino Uno can be programmed with the Arduino software

IDE(integrated development environment)

The Atmega328 on the Arduino Uno comes preburned with a Bootloader that allows you to
upload new code to it without the use of an external hardware programmer.

You can also bypass the Bootloader and program the microcontroller through the ICSP
(In-Circuit Serial Programming) header.
Arduino UNO
(C) MELabs (Mobile Embedded Labs Pvt.Ltd)
UNO SPECIFCATION
(C) MELabs (Mobile Embedded Labs Pvt.Ltd)
●
The Arduino Uno can be programmed with the Arduino software
●
Microcontroller – Atmega328
●
Operating Voltage 5V and 3.3 V
●
Digital I/O Pins -14
●
Analog Input Pins 6
●
Flash Memory 32 KB (ATmega328) of which 0.5 KB used by Bootloader
●
SRAM – 2KB
●
EEPROM -1KB
MEMORY/STORAGE
(C) MELabs (Mobile Embedded Labs Pvt.Ltd)

There are three pools of memory in the microcontroller used on avr-based Arduino
boards :

Flash memory (program space), is where the Arduino sketch is stored.

SRAM (static random access memory) is where the sketch creates and manipulates variables
when it runs.

EEPROM is memory space that programmers can use to store long-term information.

Flash memory and EEPROM memory are non-volatile (the information persists after
the power is turned off). SRAM is volatile and will be lost when the power is cycled.
ARDUINO PROGRAMMING -GLOSSARY
(C) MELabs (Mobile Embedded Labs Pvt.Ltd)
●
Sketch – Program that runs on the board
●
Pin – Input or Output connected to something – Eg: Output to an LED input to an
Switch
●
Digital – 1 (high) or 0 (Low) -ON/OFF
●
Analog – Range 0-255 (Led brightness)
●
Arduino IDE – Comes with C/C++ lib named as Wiring
●
Programs are written in C & C++ but only having two funtcions -
Setup() - Called once at the start of program, works as initialiser
Loop() - Called repeatedly until the board is powered-off
SKETCH
(C) MELabs (Mobile Embedded Labs Pvt.Ltd)
Global Variables
setup()
loop()
Variable Declaration
Initialise
loop
C++ Lib
C/C++
Readable Code
C/C++
Readable Code
Assembly Readable
Code
Machine Language
SKETCH -setup()/loop()
(C) MELabs (Mobile Embedded Labs Pvt.Ltd)
setup()
pinMode() - set pin as input or output
serialBegin() - Set to talk to the computer
loop()
digitalWrite() - set digital pin as high/low
digtialRead() -read a digital pin state
wait()- wait an amount of time
SKETCH -Example
(C) MELabs (Mobile Embedded Labs Pvt.Ltd)
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
For Statement -example
(C) MELabs (Mobile Embedded Labs Pvt.Ltd)
// Dim an LED using a PWM pin
int PWMpin = 10; // LED in series with 470 ohm resistor on pin 10
void setup()
{
// no setup needed
}
void loop()
{
for (int i=0; i <= 255; i++) {
analogWrite(PWMpin, i);
//Writes an analog value (PWM wave) to a pin. Can be used to light a LED at varying brightnesses or
drive a motor at various speeds
delay(10);
}
}
If --- else
MELabs (Mobile Embedded Labs Pvt.Ltd)
The if statement checks for a condition and executes the proceeding statement or set
of statements if the condition is 'true'.
Syntax
if (condition)
{
//statement(s)
}
Parameters
condition: a boolean expression i.e., can be true or false
Switch/Case statements
MELabs (Mobile Embedded Labs Pvt.Ltd)
switch (var) {
case 1:
//do something when var equals 1
break;
case 2:
//do something when var equals 2
break;
default:
// if nothing else matches, do the default
// default is optional
}
For Statement
(C) MELabs (Mobile Embedded Labs Pvt.Ltd)

The for statement is used to repeat a block of statements enclosed in curly braces.

An increment counter is usually used to increment and terminate the loop.

The for statement is useful for any repetitive operation, and is often used in
combination with arrays to operate on collections of data/pins.
for (initialization; condition; increment) {
//statement(s);
}
For Statement -example
(C) MELabs (Mobile Embedded Labs Pvt.Ltd)
// Dim an LED using a PWM pin
int PWMpin = 10; // LED in series with 470 ohm resistor on pin 10
void setup()
{
// no setup needed
}
void loop()
{
for (int i=0; i <= 255; i++) {
analogWrite(PWMpin, i);
//Writes an analog value (PWM wave) to a pin. Can be used to light a LED at varying brightnesses or
drive a motor at various speeds
delay(10);
}
}
while statement
(C) MELabs (Mobile Embedded Labs Pvt.Ltd)
A while loop will loop continuously, and infinitely, until the expression inside
the parenthesis, () becomes false.
while(condition){
// statement(s)
}
Example :
var = 0;
while(var < 200){
// do something repetitive 200 times
var++;
}
Do – While statement
(C) MELabs (Mobile Embedded Labs Pvt.Ltd)
The do…while loop works in the same manner as the while loop, with the exception
that the condition is tested at the end of the loop, so the do loop will always run at
least once.
do
{
// statement block
} while (condition);
Example -
do
{
delay(50); // wait for sensors to stabilize
x = readSensors(); // check the sensors
} while (x < 100);
Data Types
(C) MELabs (Mobile Embedded Labs Pvt.Ltd)
●
Integers, booleans, and characters
●
Float: Data type for floating point numbers (those with a decimal point). They can range
from 3.4028235E+38 down to -3.4028235E+38. Stored as 32 bits (4 bytes).
●
Long: Data type for larger numbers, from -2,147,483,648 to 2,147,483,647, and store
32 bits (4 bytes) of information.
●
String: On the Arduino, there are really two kinds of strings: strings (with a lower case s )ʻ ʼ
can be created as an array of characters (of type char). String (with a capital S ), is a Stringʻ ʼ
type object.
Char stringArray[10] = “isdi”;
String stringObject = String(“isdi”);
The advantage of the second method (using the String object) is that it allows you to use a number of built-in methods,
such as length(), replace(), and equals().
ARDUINO -Libraries
(C) MELabs (Mobile Embedded Labs Pvt.Ltd)
Libraries provide extra functionality for use in sketches, e.g. working with hardware
or manipulating data. To use a library in a sketch.
select it from Sketch > Import Library.
Standard Libraries
(C) MELabs (Mobile Embedded Labs Pvt.Ltd)

EEPROM - reading and writing to "permanent" storage


Ethernet / Ethernet 2 - for connecting to the internet using the Arduino Ethernet Shield, Arduino Ethernet Shield 2 and Arduino
Leonardo ETH


Firmata - for communicating with applications on the computer using a standard serial protocol.


GSM - for connecting to a GSM/GRPS network with the GSM shield.


LiquidCrystal - for controlling liquid crystal displays (LCDs)


SD - for reading and writing SD cards


Servo - for controlling servo motors


SPI - for communicating with devices using the Serial Peripheral Interface (SPI) Bus


Stepper - for controlling stepper motors


TFT - for drawing text , images, and shapes on the Arduino TFT screen


WiFi - for connecting to the internet using the Arduino WiFi shield

More Related Content

What's hot (20)

Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
ABHISHEK fulwadhwa
 
chp3-Sensors, Actuators, and Microcontroller
chp3-Sensors, Actuators, and Microcontrollerchp3-Sensors, Actuators, and Microcontroller
chp3-Sensors, Actuators, and Microcontroller
ssuser06ea42
 
Registers and counters
Registers and counters Registers and counters
Registers and counters
Deepak John
 
Discrete mathematics
Discrete mathematicsDiscrete mathematics
Discrete mathematics
University of Potsdam
 
Embedded C programming based on 8051 microcontroller
Embedded C programming based on 8051 microcontrollerEmbedded C programming based on 8051 microcontroller
Embedded C programming based on 8051 microcontroller
Gaurav Verma
 
C programming notes.pdf
C programming notes.pdfC programming notes.pdf
C programming notes.pdf
AdiseshaK
 
Storage classes in C
Storage classes in C Storage classes in C
Storage classes in C
Self employed
 
What is keyword in c programming
What is keyword in c programmingWhat is keyword in c programming
What is keyword in c programming
Rumman Ansari
 
Digital Clock Using Logic Gates
Digital Clock Using Logic GatesDigital Clock Using Logic Gates
Digital Clock Using Logic Gates
JalpaMaheshwari1
 
C tokens
C tokensC tokens
C tokens
Manu1325
 
Arduino course
Arduino courseArduino course
Arduino course
Ahmed Shelbaya
 
Data representation
Data representationData representation
Data representation
shashikant pabari
 
digital logic design number system
digital logic design number systemdigital logic design number system
digital logic design number system
Nallapati Anindra
 
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauri
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauriArduino for beginners- Introduction to Arduino (presentation) - codewithgauri
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauri
Gaurav Pandey
 
Logic gates presentation
Logic gates presentationLogic gates presentation
Logic gates presentation
priyanka bisarya
 
Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
programming9
 
Arduino Platform with C programming.
Arduino Platform with C programming.Arduino Platform with C programming.
Arduino Platform with C programming.
Govind Jha
 
Introduction to Node MCU
Introduction to Node MCUIntroduction to Node MCU
Introduction to Node MCU
Amarjeetsingh Thakur
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
Vineeta Garg
 
VHDL-Behavioral-Programs-Structure of VHDL
VHDL-Behavioral-Programs-Structure of VHDLVHDL-Behavioral-Programs-Structure of VHDL
VHDL-Behavioral-Programs-Structure of VHDL
Revathi Subramaniam
 
chp3-Sensors, Actuators, and Microcontroller
chp3-Sensors, Actuators, and Microcontrollerchp3-Sensors, Actuators, and Microcontroller
chp3-Sensors, Actuators, and Microcontroller
ssuser06ea42
 
Registers and counters
Registers and counters Registers and counters
Registers and counters
Deepak John
 
Embedded C programming based on 8051 microcontroller
Embedded C programming based on 8051 microcontrollerEmbedded C programming based on 8051 microcontroller
Embedded C programming based on 8051 microcontroller
Gaurav Verma
 
C programming notes.pdf
C programming notes.pdfC programming notes.pdf
C programming notes.pdf
AdiseshaK
 
Storage classes in C
Storage classes in C Storage classes in C
Storage classes in C
Self employed
 
What is keyword in c programming
What is keyword in c programmingWhat is keyword in c programming
What is keyword in c programming
Rumman Ansari
 
Digital Clock Using Logic Gates
Digital Clock Using Logic GatesDigital Clock Using Logic Gates
Digital Clock Using Logic Gates
JalpaMaheshwari1
 
digital logic design number system
digital logic design number systemdigital logic design number system
digital logic design number system
Nallapati Anindra
 
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauri
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauriArduino for beginners- Introduction to Arduino (presentation) - codewithgauri
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauri
Gaurav Pandey
 
Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
programming9
 
Arduino Platform with C programming.
Arduino Platform with C programming.Arduino Platform with C programming.
Arduino Platform with C programming.
Govind Jha
 
VHDL-Behavioral-Programs-Structure of VHDL
VHDL-Behavioral-Programs-Structure of VHDLVHDL-Behavioral-Programs-Structure of VHDL
VHDL-Behavioral-Programs-Structure of VHDL
Revathi Subramaniam
 

Similar to Arduino programming (20)

Arduino board program for Mobile robotss
Arduino board program for Mobile robotssArduino board program for Mobile robotss
Arduino board program for Mobile robotss
VSARAVANAKUMARHICETS
 
Introduction to Arduino Microcontroller
Introduction to Arduino MicrocontrollerIntroduction to Arduino Microcontroller
Introduction to Arduino Microcontroller
Mujahid Hussain
 
Arduino reference
Arduino referenceArduino reference
Arduino reference
Marcos Henrique
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
Mohamed Zain Allam
 
Introduction to the Arduino
Introduction to the ArduinoIntroduction to the Arduino
Introduction to the Arduino
Wingston
 
Arduino for Beginners
Arduino for BeginnersArduino for Beginners
Arduino for Beginners
Sarwan Singh
 
Introduction of Arduino Uno
Introduction of Arduino UnoIntroduction of Arduino Uno
Introduction of Arduino Uno
Md. Nahidul Islam
 
Programming arduino makeymakey
Programming arduino makeymakeyProgramming arduino makeymakey
Programming arduino makeymakey
Industrial Design Center
 
arduino
arduinoarduino
arduino
murbz
 
Arduino Programming Basic
Arduino Programming BasicArduino Programming Basic
Arduino Programming Basic
LITS IT Ltd,LASRC.SPACE,SAWDAGOR BD,FREELANCE BD,iREV,BD LAW ACADEMY,SMART AVI,HEA,HFSAC LTD.
 
Ch_2_8,9,10.pptx
Ch_2_8,9,10.pptxCh_2_8,9,10.pptx
Ch_2_8,9,10.pptx
yosikit826
 
Arduino by yogesh t s'
Arduino by yogesh t s'Arduino by yogesh t s'
Arduino by yogesh t s'
tsyogesh46
 
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
Jayanthi Kannan MK
 
The IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programmingThe IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programming
The IOT Academy
 
Intro to Arduino Programming.pdf
Intro to Arduino Programming.pdfIntro to Arduino Programming.pdf
Intro to Arduino Programming.pdf
HimanshuDon1
 
Arduino section programming slides
Arduino section programming slidesArduino section programming slides
Arduino section programming slides
vivek k
 
Lesson-4-Arduino-Programming-dsBasics.pdf
Lesson-4-Arduino-Programming-dsBasics.pdfLesson-4-Arduino-Programming-dsBasics.pdf
Lesson-4-Arduino-Programming-dsBasics.pdf
unicaeli2020
 
Arduino Section Programming - from Sparkfun
Arduino Section Programming - from SparkfunArduino Section Programming - from Sparkfun
Arduino Section Programming - from Sparkfun
JhaeZaSangcapGarrido
 
Arduino: Arduino starter kit
Arduino: Arduino starter kitArduino: Arduino starter kit
Arduino: Arduino starter kit
SANTIAGO PABLO ALBERTO
 
ARDUINO Presentation1.pptx
ARDUINO Presentation1.pptxARDUINO Presentation1.pptx
ARDUINO Presentation1.pptx
SourabhSalunkhe10
 
Arduino board program for Mobile robotss
Arduino board program for Mobile robotssArduino board program for Mobile robotss
Arduino board program for Mobile robotss
VSARAVANAKUMARHICETS
 
Introduction to Arduino Microcontroller
Introduction to Arduino MicrocontrollerIntroduction to Arduino Microcontroller
Introduction to Arduino Microcontroller
Mujahid Hussain
 
Introduction to the Arduino
Introduction to the ArduinoIntroduction to the Arduino
Introduction to the Arduino
Wingston
 
Arduino for Beginners
Arduino for BeginnersArduino for Beginners
Arduino for Beginners
Sarwan Singh
 
arduino
arduinoarduino
arduino
murbz
 
Ch_2_8,9,10.pptx
Ch_2_8,9,10.pptxCh_2_8,9,10.pptx
Ch_2_8,9,10.pptx
yosikit826
 
Arduino by yogesh t s'
Arduino by yogesh t s'Arduino by yogesh t s'
Arduino by yogesh t s'
tsyogesh46
 
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
Jayanthi Kannan MK
 
The IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programmingThe IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programming
The IOT Academy
 
Intro to Arduino Programming.pdf
Intro to Arduino Programming.pdfIntro to Arduino Programming.pdf
Intro to Arduino Programming.pdf
HimanshuDon1
 
Arduino section programming slides
Arduino section programming slidesArduino section programming slides
Arduino section programming slides
vivek k
 
Lesson-4-Arduino-Programming-dsBasics.pdf
Lesson-4-Arduino-Programming-dsBasics.pdfLesson-4-Arduino-Programming-dsBasics.pdf
Lesson-4-Arduino-Programming-dsBasics.pdf
unicaeli2020
 
Arduino Section Programming - from Sparkfun
Arduino Section Programming - from SparkfunArduino Section Programming - from Sparkfun
Arduino Section Programming - from Sparkfun
JhaeZaSangcapGarrido
 
Ad

More from Siji Sunny (11)

Universal Configuration Interface
Universal Configuration InterfaceUniversal Configuration Interface
Universal Configuration Interface
Siji Sunny
 
OpenSource IoT Middleware Frameworks
OpenSource IoT Middleware FrameworksOpenSource IoT Middleware Frameworks
OpenSource IoT Middleware Frameworks
Siji Sunny
 
Vedic Sanskrit-on the way of Digitization
Vedic Sanskrit-on the way of DigitizationVedic Sanskrit-on the way of Digitization
Vedic Sanskrit-on the way of Digitization
Siji Sunny
 
Indian Language App.Development Framework for Android
Indian Language App.Development Framework for AndroidIndian Language App.Development Framework for Android
Indian Language App.Development Framework for Android
Siji Sunny
 
A deep dive into Android OpenSource Project(AOSP)
A deep dive into Android OpenSource Project(AOSP)A deep dive into Android OpenSource Project(AOSP)
A deep dive into Android OpenSource Project(AOSP)
Siji Sunny
 
Unified Text Layout Engine for FOSS Systems -Paper
Unified Text Layout Engine for FOSS Systems -PaperUnified Text Layout Engine for FOSS Systems -Paper
Unified Text Layout Engine for FOSS Systems -Paper
Siji Sunny
 
Unified Text Layout Engine for FOSS Systems
Unified Text Layout Engine for FOSS SystemsUnified Text Layout Engine for FOSS Systems
Unified Text Layout Engine for FOSS Systems
Siji Sunny
 
Android System Developement
Android System DevelopementAndroid System Developement
Android System Developement
Siji Sunny
 
Debian on ARM - Gnunify2015
Debian on ARM - Gnunify2015Debian on ARM - Gnunify2015
Debian on ARM - Gnunify2015
Siji Sunny
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
Siji Sunny
 
OpenSource Hardware -Debian Way
OpenSource Hardware -Debian WayOpenSource Hardware -Debian Way
OpenSource Hardware -Debian Way
Siji Sunny
 
Universal Configuration Interface
Universal Configuration InterfaceUniversal Configuration Interface
Universal Configuration Interface
Siji Sunny
 
OpenSource IoT Middleware Frameworks
OpenSource IoT Middleware FrameworksOpenSource IoT Middleware Frameworks
OpenSource IoT Middleware Frameworks
Siji Sunny
 
Vedic Sanskrit-on the way of Digitization
Vedic Sanskrit-on the way of DigitizationVedic Sanskrit-on the way of Digitization
Vedic Sanskrit-on the way of Digitization
Siji Sunny
 
Indian Language App.Development Framework for Android
Indian Language App.Development Framework for AndroidIndian Language App.Development Framework for Android
Indian Language App.Development Framework for Android
Siji Sunny
 
A deep dive into Android OpenSource Project(AOSP)
A deep dive into Android OpenSource Project(AOSP)A deep dive into Android OpenSource Project(AOSP)
A deep dive into Android OpenSource Project(AOSP)
Siji Sunny
 
Unified Text Layout Engine for FOSS Systems -Paper
Unified Text Layout Engine for FOSS Systems -PaperUnified Text Layout Engine for FOSS Systems -Paper
Unified Text Layout Engine for FOSS Systems -Paper
Siji Sunny
 
Unified Text Layout Engine for FOSS Systems
Unified Text Layout Engine for FOSS SystemsUnified Text Layout Engine for FOSS Systems
Unified Text Layout Engine for FOSS Systems
Siji Sunny
 
Android System Developement
Android System DevelopementAndroid System Developement
Android System Developement
Siji Sunny
 
Debian on ARM - Gnunify2015
Debian on ARM - Gnunify2015Debian on ARM - Gnunify2015
Debian on ARM - Gnunify2015
Siji Sunny
 
OpenSource Hardware -Debian Way
OpenSource Hardware -Debian WayOpenSource Hardware -Debian Way
OpenSource Hardware -Debian Way
Siji Sunny
 
Ad

Recently uploaded (20)

A Comprehensive Investigation into the Accuracy of Soft Computing Tools for D...
A Comprehensive Investigation into the Accuracy of Soft Computing Tools for D...A Comprehensive Investigation into the Accuracy of Soft Computing Tools for D...
A Comprehensive Investigation into the Accuracy of Soft Computing Tools for D...
Journal of Soft Computing in Civil Engineering
 
Introduction to AI agent development with MCP
Introduction to AI agent development with MCPIntroduction to AI agent development with MCP
Introduction to AI agent development with MCP
Dori Waldman
 
Software Engineering Project Presentation Tanisha Tasnuva
Software Engineering Project Presentation Tanisha TasnuvaSoftware Engineering Project Presentation Tanisha Tasnuva
Software Engineering Project Presentation Tanisha Tasnuva
tanishatasnuva76
 
Presentación Tomografía Axial Computarizada
Presentación Tomografía Axial ComputarizadaPresentación Tomografía Axial Computarizada
Presentación Tomografía Axial Computarizada
Juliana Ovalle Jiménez
 
ACEP Magazine Fifth Edition on 5june2025
ACEP Magazine Fifth Edition on 5june2025ACEP Magazine Fifth Edition on 5june2025
ACEP Magazine Fifth Edition on 5june2025
Rahul
 
May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...
May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...
May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...
sebastianku31
 
introduction to Digital Signature basics
introduction to Digital Signature basicsintroduction to Digital Signature basics
introduction to Digital Signature basics
DhavalPatel171802
 
What is dbms architecture, components of dbms architecture and types of dbms ...
What is dbms architecture, components of dbms architecture and types of dbms ...What is dbms architecture, components of dbms architecture and types of dbms ...
What is dbms architecture, components of dbms architecture and types of dbms ...
cyhuutjdoazdwrnubt
 
Research_Sensitization_&_Innovative_Project_Development.pptx
Research_Sensitization_&_Innovative_Project_Development.pptxResearch_Sensitization_&_Innovative_Project_Development.pptx
Research_Sensitization_&_Innovative_Project_Development.pptx
niranjancse
 
Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...
Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...
Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...
Mohamed905031
 
Direct Current circuitsDirect Current circuitsDirect Current circuitsDirect C...
Direct Current circuitsDirect Current circuitsDirect Current circuitsDirect C...Direct Current circuitsDirect Current circuitsDirect Current circuitsDirect C...
Direct Current circuitsDirect Current circuitsDirect Current circuitsDirect C...
BeHappy728244
 
Introduction of Structural Audit and Health Montoring.pptx
Introduction of Structural Audit and Health Montoring.pptxIntroduction of Structural Audit and Health Montoring.pptx
Introduction of Structural Audit and Health Montoring.pptx
gunjalsachin
 
Forecasting Road Accidents Using Deep Learning Approach: Policies to Improve ...
Forecasting Road Accidents Using Deep Learning Approach: Policies to Improve ...Forecasting Road Accidents Using Deep Learning Approach: Policies to Improve ...
Forecasting Road Accidents Using Deep Learning Approach: Policies to Improve ...
Journal of Soft Computing in Civil Engineering
 
"The Enigmas of the Riemann Hypothesis" by Julio Chai
"The Enigmas of the Riemann Hypothesis" by Julio Chai"The Enigmas of the Riemann Hypothesis" by Julio Chai
"The Enigmas of the Riemann Hypothesis" by Julio Chai
Julio Chai
 
Software Developer Portfolio: Backend Architecture & Performance Optimization
Software Developer Portfolio: Backend Architecture & Performance OptimizationSoftware Developer Portfolio: Backend Architecture & Performance Optimization
Software Developer Portfolio: Backend Architecture & Performance Optimization
kiwoong (daniel) kim
 
Artificial Power 2025 raport krajobrazowy
Artificial Power 2025 raport krajobrazowyArtificial Power 2025 raport krajobrazowy
Artificial Power 2025 raport krajobrazowy
dominikamizerska1
 
22PCOAM16 _ML_Unit 3 Notes & Question bank
22PCOAM16 _ML_Unit 3 Notes & Question bank22PCOAM16 _ML_Unit 3 Notes & Question bank
22PCOAM16 _ML_Unit 3 Notes & Question bank
Guru Nanak Technical Institutions
 
First Review PPT gfinal gyft ftu liu yrfut go
First Review PPT gfinal gyft  ftu liu yrfut goFirst Review PPT gfinal gyft  ftu liu yrfut go
First Review PPT gfinal gyft ftu liu yrfut go
Sowndarya6
 
fHUINhKG5lM1WBBk608.pptxfhjjhhjffhiuhhghj
fHUINhKG5lM1WBBk608.pptxfhjjhhjffhiuhhghjfHUINhKG5lM1WBBk608.pptxfhjjhhjffhiuhhghj
fHUINhKG5lM1WBBk608.pptxfhjjhhjffhiuhhghj
yadavshivank2006
 
Axial Capacity Estimation of FRP-strengthened Corroded Concrete Columns
Axial Capacity Estimation of FRP-strengthened Corroded Concrete ColumnsAxial Capacity Estimation of FRP-strengthened Corroded Concrete Columns
Axial Capacity Estimation of FRP-strengthened Corroded Concrete Columns
Journal of Soft Computing in Civil Engineering
 
Introduction to AI agent development with MCP
Introduction to AI agent development with MCPIntroduction to AI agent development with MCP
Introduction to AI agent development with MCP
Dori Waldman
 
Software Engineering Project Presentation Tanisha Tasnuva
Software Engineering Project Presentation Tanisha TasnuvaSoftware Engineering Project Presentation Tanisha Tasnuva
Software Engineering Project Presentation Tanisha Tasnuva
tanishatasnuva76
 
Presentación Tomografía Axial Computarizada
Presentación Tomografía Axial ComputarizadaPresentación Tomografía Axial Computarizada
Presentación Tomografía Axial Computarizada
Juliana Ovalle Jiménez
 
ACEP Magazine Fifth Edition on 5june2025
ACEP Magazine Fifth Edition on 5june2025ACEP Magazine Fifth Edition on 5june2025
ACEP Magazine Fifth Edition on 5june2025
Rahul
 
May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...
May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...
May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...
sebastianku31
 
introduction to Digital Signature basics
introduction to Digital Signature basicsintroduction to Digital Signature basics
introduction to Digital Signature basics
DhavalPatel171802
 
What is dbms architecture, components of dbms architecture and types of dbms ...
What is dbms architecture, components of dbms architecture and types of dbms ...What is dbms architecture, components of dbms architecture and types of dbms ...
What is dbms architecture, components of dbms architecture and types of dbms ...
cyhuutjdoazdwrnubt
 
Research_Sensitization_&_Innovative_Project_Development.pptx
Research_Sensitization_&_Innovative_Project_Development.pptxResearch_Sensitization_&_Innovative_Project_Development.pptx
Research_Sensitization_&_Innovative_Project_Development.pptx
niranjancse
 
Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...
Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...
Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...
Mohamed905031
 
Direct Current circuitsDirect Current circuitsDirect Current circuitsDirect C...
Direct Current circuitsDirect Current circuitsDirect Current circuitsDirect C...Direct Current circuitsDirect Current circuitsDirect Current circuitsDirect C...
Direct Current circuitsDirect Current circuitsDirect Current circuitsDirect C...
BeHappy728244
 
Introduction of Structural Audit and Health Montoring.pptx
Introduction of Structural Audit and Health Montoring.pptxIntroduction of Structural Audit and Health Montoring.pptx
Introduction of Structural Audit and Health Montoring.pptx
gunjalsachin
 
"The Enigmas of the Riemann Hypothesis" by Julio Chai
"The Enigmas of the Riemann Hypothesis" by Julio Chai"The Enigmas of the Riemann Hypothesis" by Julio Chai
"The Enigmas of the Riemann Hypothesis" by Julio Chai
Julio Chai
 
Software Developer Portfolio: Backend Architecture & Performance Optimization
Software Developer Portfolio: Backend Architecture & Performance OptimizationSoftware Developer Portfolio: Backend Architecture & Performance Optimization
Software Developer Portfolio: Backend Architecture & Performance Optimization
kiwoong (daniel) kim
 
Artificial Power 2025 raport krajobrazowy
Artificial Power 2025 raport krajobrazowyArtificial Power 2025 raport krajobrazowy
Artificial Power 2025 raport krajobrazowy
dominikamizerska1
 
First Review PPT gfinal gyft ftu liu yrfut go
First Review PPT gfinal gyft  ftu liu yrfut goFirst Review PPT gfinal gyft  ftu liu yrfut go
First Review PPT gfinal gyft ftu liu yrfut go
Sowndarya6
 
fHUINhKG5lM1WBBk608.pptxfhjjhhjffhiuhhghj
fHUINhKG5lM1WBBk608.pptxfhjjhhjffhiuhhghjfHUINhKG5lM1WBBk608.pptxfhjjhhjffhiuhhghj
fHUINhKG5lM1WBBk608.pptxfhjjhhjffhiuhhghj
yadavshivank2006
 

Arduino programming

  • 1. • Introduction to Arduino • UNO Overview • Programming Basics • Arduino Libraires l Siji Sunny [email protected] Arduino Programming (For Beginners)
  • 2. WHAT IS ARDUINO (C) MELabs (Mobile Embedded Labs Pvt.Ltd)  The Arduino project started in 2003 as a program for students at the Interaction Design Institute Ivrea in Ivrea, Italy  Open Source Hardware and Software Platform  single-board microcontroller  Allows to building digital devices and interactive objects that can sense and control objects in the physical world.
  • 3. DEVELOPMENT ENVIRONMENT (C) MELabs (Mobile Embedded Labs Pvt.Ltd)  The Arduino Uno can be programmed with the Arduino software  IDE(integrated development environment)  The Atmega328 on the Arduino Uno comes preburned with a Bootloader that allows you to upload new code to it without the use of an external hardware programmer.  You can also bypass the Bootloader and program the microcontroller through the ICSP (In-Circuit Serial Programming) header.
  • 4. Arduino UNO (C) MELabs (Mobile Embedded Labs Pvt.Ltd)
  • 5. UNO SPECIFCATION (C) MELabs (Mobile Embedded Labs Pvt.Ltd) ● The Arduino Uno can be programmed with the Arduino software ● Microcontroller – Atmega328 ● Operating Voltage 5V and 3.3 V ● Digital I/O Pins -14 ● Analog Input Pins 6 ● Flash Memory 32 KB (ATmega328) of which 0.5 KB used by Bootloader ● SRAM – 2KB ● EEPROM -1KB
  • 6. MEMORY/STORAGE (C) MELabs (Mobile Embedded Labs Pvt.Ltd)  There are three pools of memory in the microcontroller used on avr-based Arduino boards :  Flash memory (program space), is where the Arduino sketch is stored.  SRAM (static random access memory) is where the sketch creates and manipulates variables when it runs.  EEPROM is memory space that programmers can use to store long-term information.  Flash memory and EEPROM memory are non-volatile (the information persists after the power is turned off). SRAM is volatile and will be lost when the power is cycled.
  • 7. ARDUINO PROGRAMMING -GLOSSARY (C) MELabs (Mobile Embedded Labs Pvt.Ltd) ● Sketch – Program that runs on the board ● Pin – Input or Output connected to something – Eg: Output to an LED input to an Switch ● Digital – 1 (high) or 0 (Low) -ON/OFF ● Analog – Range 0-255 (Led brightness) ● Arduino IDE – Comes with C/C++ lib named as Wiring ● Programs are written in C & C++ but only having two funtcions - Setup() - Called once at the start of program, works as initialiser Loop() - Called repeatedly until the board is powered-off
  • 8. SKETCH (C) MELabs (Mobile Embedded Labs Pvt.Ltd) Global Variables setup() loop() Variable Declaration Initialise loop C++ Lib C/C++ Readable Code C/C++ Readable Code Assembly Readable Code Machine Language
  • 9. SKETCH -setup()/loop() (C) MELabs (Mobile Embedded Labs Pvt.Ltd) setup() pinMode() - set pin as input or output serialBegin() - Set to talk to the computer loop() digitalWrite() - set digital pin as high/low digtialRead() -read a digital pin state wait()- wait an amount of time
  • 10. SKETCH -Example (C) MELabs (Mobile Embedded Labs Pvt.Ltd) // the setup function runs once when you press reset or power the board void setup() { // initialize digital pin LED_BUILTIN as an output. pinMode(LED_BUILTIN, OUTPUT); } // the loop function runs over and over again forever void loop() { digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }
  • 11. For Statement -example (C) MELabs (Mobile Embedded Labs Pvt.Ltd) // Dim an LED using a PWM pin int PWMpin = 10; // LED in series with 470 ohm resistor on pin 10 void setup() { // no setup needed } void loop() { for (int i=0; i <= 255; i++) { analogWrite(PWMpin, i); //Writes an analog value (PWM wave) to a pin. Can be used to light a LED at varying brightnesses or drive a motor at various speeds delay(10); } }
  • 12. If --- else MELabs (Mobile Embedded Labs Pvt.Ltd) The if statement checks for a condition and executes the proceeding statement or set of statements if the condition is 'true'. Syntax if (condition) { //statement(s) } Parameters condition: a boolean expression i.e., can be true or false
  • 13. Switch/Case statements MELabs (Mobile Embedded Labs Pvt.Ltd) switch (var) { case 1: //do something when var equals 1 break; case 2: //do something when var equals 2 break; default: // if nothing else matches, do the default // default is optional }
  • 14. For Statement (C) MELabs (Mobile Embedded Labs Pvt.Ltd)  The for statement is used to repeat a block of statements enclosed in curly braces.  An increment counter is usually used to increment and terminate the loop.  The for statement is useful for any repetitive operation, and is often used in combination with arrays to operate on collections of data/pins. for (initialization; condition; increment) { //statement(s); }
  • 15. For Statement -example (C) MELabs (Mobile Embedded Labs Pvt.Ltd) // Dim an LED using a PWM pin int PWMpin = 10; // LED in series with 470 ohm resistor on pin 10 void setup() { // no setup needed } void loop() { for (int i=0; i <= 255; i++) { analogWrite(PWMpin, i); //Writes an analog value (PWM wave) to a pin. Can be used to light a LED at varying brightnesses or drive a motor at various speeds delay(10); } }
  • 16. while statement (C) MELabs (Mobile Embedded Labs Pvt.Ltd) A while loop will loop continuously, and infinitely, until the expression inside the parenthesis, () becomes false. while(condition){ // statement(s) } Example : var = 0; while(var < 200){ // do something repetitive 200 times var++; }
  • 17. Do – While statement (C) MELabs (Mobile Embedded Labs Pvt.Ltd) The do…while loop works in the same manner as the while loop, with the exception that the condition is tested at the end of the loop, so the do loop will always run at least once. do { // statement block } while (condition); Example - do { delay(50); // wait for sensors to stabilize x = readSensors(); // check the sensors } while (x < 100);
  • 18. Data Types (C) MELabs (Mobile Embedded Labs Pvt.Ltd) ● Integers, booleans, and characters ● Float: Data type for floating point numbers (those with a decimal point). They can range from 3.4028235E+38 down to -3.4028235E+38. Stored as 32 bits (4 bytes). ● Long: Data type for larger numbers, from -2,147,483,648 to 2,147,483,647, and store 32 bits (4 bytes) of information. ● String: On the Arduino, there are really two kinds of strings: strings (with a lower case s )ʻ ʼ can be created as an array of characters (of type char). String (with a capital S ), is a Stringʻ ʼ type object. Char stringArray[10] = “isdi”; String stringObject = String(“isdi”); The advantage of the second method (using the String object) is that it allows you to use a number of built-in methods, such as length(), replace(), and equals().
  • 19. ARDUINO -Libraries (C) MELabs (Mobile Embedded Labs Pvt.Ltd) Libraries provide extra functionality for use in sketches, e.g. working with hardware or manipulating data. To use a library in a sketch. select it from Sketch > Import Library.
  • 20. Standard Libraries (C) MELabs (Mobile Embedded Labs Pvt.Ltd)  EEPROM - reading and writing to "permanent" storage   Ethernet / Ethernet 2 - for connecting to the internet using the Arduino Ethernet Shield, Arduino Ethernet Shield 2 and Arduino Leonardo ETH   Firmata - for communicating with applications on the computer using a standard serial protocol.   GSM - for connecting to a GSM/GRPS network with the GSM shield.   LiquidCrystal - for controlling liquid crystal displays (LCDs)   SD - for reading and writing SD cards   Servo - for controlling servo motors   SPI - for communicating with devices using the Serial Peripheral Interface (SPI) Bus   Stepper - for controlling stepper motors   TFT - for drawing text , images, and shapes on the Arduino TFT screen   WiFi - for connecting to the internet using the Arduino WiFi shield