SlideShare a Scribd company logo
7
Most read
12
Most read
15
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)

PDF
Part 02 Linux Kernel Module Programming
Tushar B Kute
 
PPTX
Raspberry Pi (Introduction)
Mandeesh Singh
 
PPTX
Micro controller and dsp processor
ShubhamMishra485
 
PPTX
Introduction and brief history of computers
DIrectorate of Information Technology, Govt. of KPK
 
PPTX
CPU Architecture - Basic
Yong Heui Cho
 
PDF
Bootloaders
Anil Kumar Pugalia
 
PPTX
System Booting Process overview
RajKumar Rampelli
 
PPT
Microcontroller 8051 1
khan yaseen
 
PDF
U-Boot - An universal bootloader
Emertxe Information Technologies Pvt Ltd
 
PPTX
Programming with arduino
Makers of India
 
PPT
Basic structure of computers
Kumar
 
PDF
Fast, deterministic, and verifiable computations with WebAssembly
Fluence Labs
 
PDF
Introduction to Firmware
Caroline Murphy
 
PDF
Embedded Android : System Development - Part II (Linux device drivers)
Emertxe Information Technologies Pvt Ltd
 
PPTX
Memory Organization
Kamal Acharya
 
PPTX
External Memory
Rup Chowdhury
 
PPTX
Arduino
Paras Bhanot
 
PPTX
Basics of arduino uno
Rahat Sood
 
DOCX
Vhdl
vishnu murthy
 
PPTX
arithmetic logic unit
Shimak Sharook
 
Part 02 Linux Kernel Module Programming
Tushar B Kute
 
Raspberry Pi (Introduction)
Mandeesh Singh
 
Micro controller and dsp processor
ShubhamMishra485
 
Introduction and brief history of computers
DIrectorate of Information Technology, Govt. of KPK
 
CPU Architecture - Basic
Yong Heui Cho
 
Bootloaders
Anil Kumar Pugalia
 
System Booting Process overview
RajKumar Rampelli
 
Microcontroller 8051 1
khan yaseen
 
U-Boot - An universal bootloader
Emertxe Information Technologies Pvt Ltd
 
Programming with arduino
Makers of India
 
Basic structure of computers
Kumar
 
Fast, deterministic, and verifiable computations with WebAssembly
Fluence Labs
 
Introduction to Firmware
Caroline Murphy
 
Embedded Android : System Development - Part II (Linux device drivers)
Emertxe Information Technologies Pvt Ltd
 
Memory Organization
Kamal Acharya
 
External Memory
Rup Chowdhury
 
Arduino
Paras Bhanot
 
Basics of arduino uno
Rahat Sood
 
arithmetic logic unit
Shimak Sharook
 

Similar to Arduino programming (20)

DOCX
Lab Manual Arduino UNO Microcontrollar.docx
RashidFaridChishti
 
PPT
20081114 Friday Food iLabt Bart Joris
imec.archive
 
PPSX
Arduino by yogesh t s'
tsyogesh46
 
PDF
Syed IoT - module 5
Syed Mustafa
 
PPTX
Introduction to Arduino Microcontroller
Mujahid Hussain
 
PDF
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
Jayanthi Kannan MK
 
PPSX
Arduino اردوينو
salih mahmod
 
PPTX
Arduino programming
MdAshrafulAlam47
 
PDF
Introduction of Arduino Uno
Md. Nahidul Islam
 
PPTX
Arduino workshop
mayur1432
 
PDF
Intro to Arduino Programming.pdf
HimanshuDon1
 
PDF
ARUDINO UNO and RasberryPi with Python
Jayanthi Kannan MK
 
PDF
Ardx eg-spar-web-rev10
stemplar
 
PPT
Physical prototyping lab2-analog_digital
Tony Olsson.
 
PPT
Physical prototyping lab2-analog_digital
Tony Olsson.
 
PDF
arduino
murbz
 
PPT
Intro to Arduino
avikdhupar
 
DOCX
Arduino and Circuits.docx
Ajay578679
 
PPT
Physical prototyping lab1-input_output (2)
Tony Olsson.
 
PPTX
Arduino
Jerin John
 
Lab Manual Arduino UNO Microcontrollar.docx
RashidFaridChishti
 
20081114 Friday Food iLabt Bart Joris
imec.archive
 
Arduino by yogesh t s'
tsyogesh46
 
Syed IoT - module 5
Syed Mustafa
 
Introduction to Arduino Microcontroller
Mujahid Hussain
 
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
Jayanthi Kannan MK
 
Arduino اردوينو
salih mahmod
 
Arduino programming
MdAshrafulAlam47
 
Introduction of Arduino Uno
Md. Nahidul Islam
 
Arduino workshop
mayur1432
 
Intro to Arduino Programming.pdf
HimanshuDon1
 
ARUDINO UNO and RasberryPi with Python
Jayanthi Kannan MK
 
Ardx eg-spar-web-rev10
stemplar
 
Physical prototyping lab2-analog_digital
Tony Olsson.
 
Physical prototyping lab2-analog_digital
Tony Olsson.
 
arduino
murbz
 
Intro to Arduino
avikdhupar
 
Arduino and Circuits.docx
Ajay578679
 
Physical prototyping lab1-input_output (2)
Tony Olsson.
 
Arduino
Jerin John
 
Ad

More from Siji Sunny (11)

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

Recently uploaded (20)

PDF
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
PPTX
Alan Turing - life and importance for all of us now
Pedro Concejero
 
PPTX
MODULE 04 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
PDF
AN EMPIRICAL STUDY ON THE USAGE OF SOCIAL MEDIA IN GERMAN B2C-ONLINE STORES
ijait
 
PDF
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
PDF
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
PPTX
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
PPTX
Knowledge Representation : Semantic Networks
Amity University, Patna
 
PDF
MODULE-5 notes [BCG402-CG&V] PART-B.pdf
Alvas Institute of Engineering and technology, Moodabidri
 
PPTX
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
PDF
3rd International Conference on Machine Learning and IoT (MLIoT 2025)
ClaraZara1
 
PDF
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PPTX
darshai cross section and river section analysis
muk7971
 
PDF
SERVERLESS PERSONAL TO-DO LIST APPLICATION
anushaashraf20
 
PDF
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
PDF
Digital water marking system project report
Kamal Acharya
 
PPTX
MODULE 05 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
PPTX
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
PPTX
Final Major project a b c d e f g h i j k l m
bharathpsnab
 
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
Alan Turing - life and importance for all of us now
Pedro Concejero
 
MODULE 04 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
AN EMPIRICAL STUDY ON THE USAGE OF SOCIAL MEDIA IN GERMAN B2C-ONLINE STORES
ijait
 
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
Knowledge Representation : Semantic Networks
Amity University, Patna
 
MODULE-5 notes [BCG402-CG&V] PART-B.pdf
Alvas Institute of Engineering and technology, Moodabidri
 
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
3rd International Conference on Machine Learning and IoT (MLIoT 2025)
ClaraZara1
 
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
darshai cross section and river section analysis
muk7971
 
SERVERLESS PERSONAL TO-DO LIST APPLICATION
anushaashraf20
 
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
Digital water marking system project report
Kamal Acharya
 
MODULE 05 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
Final Major project a b c d e f g h i j k l m
bharathpsnab
 

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