SlideShare a Scribd company logo
1 of 20
Download to read offline
•
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

Easy GPS Tracker using Arduino and Python
Easy GPS Tracker using Arduino and PythonEasy GPS Tracker using Arduino and Python
Easy GPS Tracker using Arduino and PythonNúria Vilanova
 
Arduino Foundations
Arduino FoundationsArduino Foundations
Arduino FoundationsJohn Breslin
 
AstroBot session 2
AstroBot session 2AstroBot session 2
AstroBot session 2osos_a215
 
arduino
arduinoarduino
arduinomurbz
 
Ee325 cmos design lab 7 report - loren k schwappach
Ee325 cmos design   lab 7 report - loren k schwappachEe325 cmos design   lab 7 report - loren k schwappach
Ee325 cmos design lab 7 report - loren k schwappachLoren Schwappach
 

What's hot (8)

Simply arduino
Simply arduinoSimply arduino
Simply arduino
 
Virtual machine re building
Virtual machine re buildingVirtual machine re building
Virtual machine re building
 
Easy GPS Tracker using Arduino and Python
Easy GPS Tracker using Arduino and PythonEasy GPS Tracker using Arduino and Python
Easy GPS Tracker using Arduino and Python
 
Arduino Foundations
Arduino FoundationsArduino Foundations
Arduino Foundations
 
AstroBot session 2
AstroBot session 2AstroBot session 2
AstroBot session 2
 
arduino
arduinoarduino
arduino
 
[ASM]Lab5
[ASM]Lab5[ASM]Lab5
[ASM]Lab5
 
Ee325 cmos design lab 7 report - loren k schwappach
Ee325 cmos design   lab 7 report - loren k schwappachEe325 cmos design   lab 7 report - loren k schwappach
Ee325 cmos design lab 7 report - loren k schwappach
 

Similar to Arduino programming

20081114 Friday Food iLabt Bart Joris
20081114 Friday Food iLabt Bart Joris20081114 Friday Food iLabt Bart Joris
20081114 Friday Food iLabt Bart Jorisimec.archive
 
Arduino by yogesh t s'
Arduino by yogesh t s'Arduino by yogesh t s'
Arduino by yogesh t s'tsyogesh46
 
Syed IoT - module 5
Syed  IoT - module 5Syed  IoT - module 5
Syed IoT - module 5Syed Mustafa
 
Basics of arduino uno
Basics of arduino unoBasics of arduino uno
Basics of arduino unoRahat Sood
 
Introduction to Arduino Microcontroller
Introduction to Arduino MicrocontrollerIntroduction to Arduino Microcontroller
Introduction to Arduino MicrocontrollerMujahid Hussain
 
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.pdfJayanthi Kannan MK
 
Arduino اردوينو
Arduino اردوينوArduino اردوينو
Arduino اردوينوsalih mahmod
 
Arduino workshop
Arduino workshopArduino workshop
Arduino workshopmayur1432
 
Intro to Arduino Programming.pdf
Intro to Arduino Programming.pdfIntro to Arduino Programming.pdf
Intro to Arduino Programming.pdfHimanshuDon1
 
ARUDINO UNO and RasberryPi with Python
 ARUDINO UNO and RasberryPi with Python ARUDINO UNO and RasberryPi with Python
ARUDINO UNO and RasberryPi with PythonJayanthi Kannan MK
 
Ardx eg-spar-web-rev10
Ardx eg-spar-web-rev10Ardx eg-spar-web-rev10
Ardx eg-spar-web-rev10stemplar
 
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalTony Olsson.
 
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalTony Olsson.
 
Intro to Arduino
Intro to ArduinoIntro to Arduino
Intro to Arduinoavikdhupar
 
Arduino and Circuits.docx
Arduino and Circuits.docxArduino and Circuits.docx
Arduino and Circuits.docxAjay578679
 
Physical prototyping lab1-input_output (2)
Physical prototyping lab1-input_output (2)Physical prototyping lab1-input_output (2)
Physical prototyping lab1-input_output (2)Tony Olsson.
 

Similar to Arduino programming (20)

20081114 Friday Food iLabt Bart Joris
20081114 Friday Food iLabt Bart Joris20081114 Friday Food iLabt Bart Joris
20081114 Friday Food iLabt Bart Joris
 
Arduino by yogesh t s'
Arduino by yogesh t s'Arduino by yogesh t s'
Arduino by yogesh t s'
 
Arduino Programming Basic
Arduino Programming BasicArduino Programming Basic
Arduino Programming Basic
 
Syed IoT - module 5
Syed  IoT - module 5Syed  IoT - module 5
Syed IoT - module 5
 
Basics of arduino uno
Basics of arduino unoBasics of arduino uno
Basics of arduino uno
 
Introduction to Arduino Microcontroller
Introduction to Arduino MicrocontrollerIntroduction to Arduino Microcontroller
Introduction to Arduino Microcontroller
 
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
 
Arduino اردوينو
Arduino اردوينوArduino اردوينو
Arduino اردوينو
 
Arduino programming
Arduino programmingArduino programming
Arduino programming
 
Introduction of Arduino Uno
Introduction of Arduino UnoIntroduction of Arduino Uno
Introduction of Arduino Uno
 
Arduino workshop
Arduino workshopArduino workshop
Arduino workshop
 
Intro to Arduino Programming.pdf
Intro to Arduino Programming.pdfIntro to Arduino Programming.pdf
Intro to Arduino Programming.pdf
 
ARUDINO UNO and RasberryPi with Python
 ARUDINO UNO and RasberryPi with Python ARUDINO UNO and RasberryPi with Python
ARUDINO UNO and RasberryPi with Python
 
Ardx eg-spar-web-rev10
Ardx eg-spar-web-rev10Ardx eg-spar-web-rev10
Ardx eg-spar-web-rev10
 
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digital
 
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digital
 
Intro to Arduino
Intro to ArduinoIntro to Arduino
Intro to Arduino
 
Arduino and Circuits.docx
Arduino and Circuits.docxArduino and Circuits.docx
Arduino and Circuits.docx
 
Physical prototyping lab1-input_output (2)
Physical prototyping lab1-input_output (2)Physical prototyping lab1-input_output (2)
Physical prototyping lab1-input_output (2)
 
Arduino
ArduinoArduino
Arduino
 

More from Siji Sunny

Universal Configuration Interface
Universal Configuration InterfaceUniversal Configuration Interface
Universal Configuration InterfaceSiji Sunny
 
OpenSource IoT Middleware Frameworks
OpenSource IoT Middleware FrameworksOpenSource IoT Middleware Frameworks
OpenSource IoT Middleware FrameworksSiji 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 DigitizationSiji 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 AndroidSiji 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 -PaperSiji 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 SystemsSiji Sunny
 
Android System Developement
Android System DevelopementAndroid System Developement
Android System DevelopementSiji Sunny
 
Debian on ARM - Gnunify2015
Debian on ARM - Gnunify2015Debian on ARM - Gnunify2015
Debian on ARM - Gnunify2015Siji Sunny
 
OpenSource Hardware -Debian Way
OpenSource Hardware -Debian WayOpenSource Hardware -Debian Way
OpenSource Hardware -Debian WaySiji Sunny
 

More from Siji Sunny (11)

Universal Configuration Interface
Universal Configuration InterfaceUniversal Configuration Interface
Universal Configuration Interface
 
OpenSource IoT Middleware Frameworks
OpenSource IoT Middleware FrameworksOpenSource IoT Middleware Frameworks
OpenSource IoT Middleware Frameworks
 
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
 
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
 
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)
 
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
 
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
 
Android System Developement
Android System DevelopementAndroid System Developement
Android System Developement
 
Debian on ARM - Gnunify2015
Debian on ARM - Gnunify2015Debian on ARM - Gnunify2015
Debian on ARM - Gnunify2015
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
 
OpenSource Hardware -Debian Way
OpenSource Hardware -Debian WayOpenSource Hardware -Debian Way
OpenSource Hardware -Debian Way
 

Recently uploaded

Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitterShivangiSharma879191
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction managementMariconPadriquez1
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniquesugginaramesh
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 

Recently uploaded (20)

Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction management
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniques
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 

Arduino programming

  • 1. • Introduction to Arduino • UNO Overview • Programming Basics • Arduino Libraires l Siji Sunny siji@melabs.in 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