SlideShare a Scribd company logo
Department of Electrical and Electronic
Engineering
Khulna University of Engineering & Technology
Khulna-9203
Course code : EE 3214
Sessional on
Microprocessors, Micro-controllers and Peripherals
Presented By
Amit Kumer Podder
Experiment No. 09
(a) Introduction to Arduino board and Arduino IDE
(b) Design and implementation of blinking LED,
analog voltage measurement, string operation and
traffic controller projects in Arduino environment
Experiment Name
Arduino is a prototype platform (open-source) based on an easy-
to-use hardware and software. It consists of a circuit board,
which can be programed (referred to as a microcontroller) and a
ready-made software called Arduino IDE (Integrated
Development Environment), which is used to write and upload
the computer code to the physical board.
Arduino
Arduino & Arduino Compatible Boards
Arduino Family
Arduino Pin Diagram
Arduino Software Outlet
Settings: Tools  Serial Port
•Your computer communicates
to the Arduino microcontroller
via a serial port  through a
USB-Serial adapter.
•Check to make sure that the
drivers are properly installed.
•Next, double-check that the proper board is selected under the
ToolsBoard menu.
Settings: Tools  Board
Arduino
Integrated Development Environment (IDE)
Two required functions /
methods / routines:
void setup()
{
// runs once
}
void loop()
{
// repeats
}error & status messages
Comments, Comments, Comments
• Comments are for you – the programmer and your
friends…or anyone else human that might read your code.
• // this is for single line comments
• // it’s good to put a description at
the top and before anything ‘tricky’
• /* this is for multi-line comments
• Like this…
• And this….
• */
comments
Comments, Comments, Comments
digitalWrite()
analogWrite()
digitalRead()
if() statements / Boolean
analogRead()
Serial communication
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
BIG6CONCEPTS
Three commands to know…
• pinMode(pin, INPUT/OUTPUT);
• ex: pinMode(13, OUTPUT);
• digitalWrite(pin, HIGH/LOW);
• ex: digitalWrite(13, HIGH);
• delay(time_ms);
• ex: delay(2500); // delay of 2.5
sec.
• // NOTE: -> commands are CASE-
sensitive
Programming Concepts: Variables
Variable Scope
•Global
•---
•Function-level
Programming Concepts: Variable Types
• Variable Types:
8 bits 16 bits 32 bits
byte
char
int
unsigned int
long
unsigned long
float
Fading in and Fading Out (Analog or Digital?)
• A few pins on the Arduino allow for us to
modify the output to mimic an analog signal.
• This is done by a technique called:
• Pulse Width Modulation (PWM)
Concepts: Analog vs. Digital
•To create an analog signal, the microcontroller uses a
technique called PWM. By varying the duty cycle, we
can mimic an “average” analog voltage.
•Pulse Width Modulation (PWM)
•analogWrite(pin, val);
•
•pin – refers to the OUTPUT pin
(limited to pins 3, 5, 6, 9, 10, 11.) –
denoted by a ~ symbol
•val – 8 bit value (0 – 255).
• 0 => 0V | 255 => 5V
Introducing a new command…
Move one of your LED pins over to Pin
9
• In Arduino, open up:
• File  Examples  01.Basics  Fade
Fade - Code Review
Fade - Code Review
Arduino Programming Familiarization
Programming: Conditional Statements
if()
• void loop()
• {
• int buttonState =
digitalRead(5);
• if(buttonState == LOW)
• { // do something
• }
• else
• { // do something else
• }
• }
Programming: Conditional
Statements
if()
DIG
INPUT
Boolean Operators
<Boolean> Description
( ) == ( ) is equal?
( ) != ( ) is not equal?
( ) > ( ) greater than
( ) >= ( ) greater than or equal
( ) < ( ) less than
( ) <= ( ) less than or equal
analogRead()
• Arduino uses a 10-bit A/D Converter:
• this means that you get input values from 0
to 1023
• 0 V  0
• 5 V  1023
•Ex:
• int sensorValue = analogRead(A0);
Using Serial Communication
Method used to transfer data between two devices.
Arduino dedicates Digital I/O pin # 0 to
receiving and Digital I/O pin #1 to transmit.
Data passes between the computer and Arduino
through the USB cable. Data is transmitted as zeros
(‘0’) and ones (‘1’) sequentially.
Serial Monitor & analogRead()
Initializes the Serial
Communication
9600 baud data rate
prints data to serial bus
Serial Monitor & analogRead()
Opens up a Serial
Terminal Window
Additional Serial Communication
Sending a Message
void loop ( )
{
Serial.print(“Hands on “) ;
Serial.print(“Learning ”) ;
• Serial.println(“is Fun!!!”) ;
}
Arduino Programming Familiarization
Serial Communication:
Serial Debugging
void loop()
{
int xVar = 10;
Serial.print ( “Variable xVar is “ ) ;
Serial.println ( xVar ) ;
}
Serial Communication:
Serial Troubleshooting
void loop ( )
{
Serial.print (“Digital pin 9: “);
Serial.println (digitalRead(9));
}
Fritzing View of Breadboard Circuit
•What happens
when you break the
circuit?
•What if you
wanted to add
more than one
LED?
Now Let’s Play With
Arduino
Program 1
Blinking of LED
void loop() {
digitalWrite(13, HIGH); // turn the LED
on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(13, LOW); // turn the LED
off by making the voltage LOW
delay(1000); // wait for a second }
void setup() {
// initialize digital pin 13 as an output.
pinMode(13, OUTPUT);
}
Program 2
Serial Blinking of LEDs
Program 3
Fading of LED
Program 4
Analog Voltage Measurement
Program 5
Traffic Signal Controller
Ad

Recommended

Arduino Microcontroller
Arduino Microcontroller
Shyam Mohan
 
Intro to Arduino
Intro to Arduino
avikdhupar
 
Basics of arduino uno
Basics of arduino uno
Rahat Sood
 
Verilog hdl
Verilog hdl
Muhammad Uzair Rasheed
 
Microprocessor and microcontrollers
Microprocessor and microcontrollers
Hiran Gabriel
 
Arduino Workshop Day 2 - Advance Arduino & DIY
Arduino Workshop Day 2 - Advance Arduino & DIY
Vishnu
 
Arduino Lecture 1 - Introducing the Arduino
Arduino Lecture 1 - Introducing the Arduino
Eoin Brazil
 
ARM Processors
ARM Processors
Mathivanan Natarajan
 
Transistor Transistor Logic
Transistor Transistor Logic
surat murthy
 
Microprocessor ppt
Microprocessor ppt
swaminath kanhere
 
Digital communication system
Digital communication system
babak danyal
 
Verilog tutorial
Verilog tutorial
Maryala Srinivas
 
Security System using XOR & NOR
Security System using XOR & NOR
Fatima Qayyum
 
Sequential cmos logic circuits
Sequential cmos logic circuits
Sakshi Bhargava
 
Vlsi design flow
Vlsi design flow
Rajendra Kumar
 
Microwave engineering basics
Microwave engineering basics
AJAL A J
 
Microprocessor & microcontroller
Microprocessor & microcontroller
Nitesh Kumar
 
8051 Microcontroller PPT's By Er. Swapnil Kaware
8051 Microcontroller PPT's By Er. Swapnil Kaware
Prof. Swapnil V. Kaware
 
Introduction to Arduino
Introduction to Arduino
yeokm1
 
Broadband antennas
Broadband antennas
AJAL A J
 
ARM CORTEX M3 PPT
ARM CORTEX M3 PPT
Gaurav Verma
 
Complex Programmable Logic Device (CPLD) Architecture and Its Applications
Complex Programmable Logic Device (CPLD) Architecture and Its Applications
elprocus
 
Electronic components ppt
Electronic components ppt
Deepjyoti Mahanta
 
Introduction to Embedded System I: Chapter 2 (5th portion)
Introduction to Embedded System I: Chapter 2 (5th portion)
Moe Moe Myint
 
Chapter 5 introduction to VHDL
Chapter 5 introduction to VHDL
SSE_AndyLi
 
Arduino IDE
Arduino IDE
Mrunal Deshkar
 
verilog code for logic gates
verilog code for logic gates
Rakesh kumar jha
 
Arduino
Arduino
Jerin John
 
Basic arduino components and more things about arduino
Basic arduino components and more things about arduino
GeorgeTsak
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
SAURABHKUMAR892774
 

More Related Content

What's hot (20)

Transistor Transistor Logic
Transistor Transistor Logic
surat murthy
 
Microprocessor ppt
Microprocessor ppt
swaminath kanhere
 
Digital communication system
Digital communication system
babak danyal
 
Verilog tutorial
Verilog tutorial
Maryala Srinivas
 
Security System using XOR & NOR
Security System using XOR & NOR
Fatima Qayyum
 
Sequential cmos logic circuits
Sequential cmos logic circuits
Sakshi Bhargava
 
Vlsi design flow
Vlsi design flow
Rajendra Kumar
 
Microwave engineering basics
Microwave engineering basics
AJAL A J
 
Microprocessor & microcontroller
Microprocessor & microcontroller
Nitesh Kumar
 
8051 Microcontroller PPT's By Er. Swapnil Kaware
8051 Microcontroller PPT's By Er. Swapnil Kaware
Prof. Swapnil V. Kaware
 
Introduction to Arduino
Introduction to Arduino
yeokm1
 
Broadband antennas
Broadband antennas
AJAL A J
 
ARM CORTEX M3 PPT
ARM CORTEX M3 PPT
Gaurav Verma
 
Complex Programmable Logic Device (CPLD) Architecture and Its Applications
Complex Programmable Logic Device (CPLD) Architecture and Its Applications
elprocus
 
Electronic components ppt
Electronic components ppt
Deepjyoti Mahanta
 
Introduction to Embedded System I: Chapter 2 (5th portion)
Introduction to Embedded System I: Chapter 2 (5th portion)
Moe Moe Myint
 
Chapter 5 introduction to VHDL
Chapter 5 introduction to VHDL
SSE_AndyLi
 
Arduino IDE
Arduino IDE
Mrunal Deshkar
 
verilog code for logic gates
verilog code for logic gates
Rakesh kumar jha
 
Arduino
Arduino
Jerin John
 
Transistor Transistor Logic
Transistor Transistor Logic
surat murthy
 
Digital communication system
Digital communication system
babak danyal
 
Security System using XOR & NOR
Security System using XOR & NOR
Fatima Qayyum
 
Sequential cmos logic circuits
Sequential cmos logic circuits
Sakshi Bhargava
 
Microwave engineering basics
Microwave engineering basics
AJAL A J
 
Microprocessor & microcontroller
Microprocessor & microcontroller
Nitesh Kumar
 
8051 Microcontroller PPT's By Er. Swapnil Kaware
8051 Microcontroller PPT's By Er. Swapnil Kaware
Prof. Swapnil V. Kaware
 
Introduction to Arduino
Introduction to Arduino
yeokm1
 
Broadband antennas
Broadband antennas
AJAL A J
 
Complex Programmable Logic Device (CPLD) Architecture and Its Applications
Complex Programmable Logic Device (CPLD) Architecture and Its Applications
elprocus
 
Introduction to Embedded System I: Chapter 2 (5th portion)
Introduction to Embedded System I: Chapter 2 (5th portion)
Moe Moe Myint
 
Chapter 5 introduction to VHDL
Chapter 5 introduction to VHDL
SSE_AndyLi
 
verilog code for logic gates
verilog code for logic gates
Rakesh kumar jha
 

Similar to Arduino Programming Familiarization (20)

Basic arduino components and more things about arduino
Basic arduino components and more things about arduino
GeorgeTsak
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
SAURABHKUMAR892774
 
Introduction to Arduino Programming
Introduction to Arduino Programming
James Lewis
 
Intro to Arduino.ppt
Intro to Arduino.ppt
jonathan Dietz
 
Intro_to_Arduino_-_v30.pptx
Intro_to_Arduino_-_v30.pptx
CephasMpandikaKalemb
 
ARUDINO UNO and RasberryPi with Python
ARUDINO UNO and RasberryPi with Python
Jayanthi Kannan MK
 
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.pdf
Jayanthi Kannan MK
 
introductiontoarduino-111120102058-phpapp02.pdf
introductiontoarduino-111120102058-phpapp02.pdf
HebaEng
 
Syed IoT - module 5
Syed IoT - module 5
Syed Mustafa
 
Audible Objects
Audible Objects
Leif Bloomquist
 
Fun with arduino
Fun with arduino
Ravikumar Tiwari
 
Arduino Programming Basic
Arduino Programming Basic
LITS IT Ltd,LASRC.SPACE,SAWDAGOR BD,FREELANCE BD,iREV,BD LAW ACADEMY,SMART AVI,HEA,HFSAC LTD.
 
Introduction to the Arduino
Introduction to the Arduino
Wingston
 
Introduction To Arduino-converted for s.pptx
Introduction To Arduino-converted for s.pptx
rtnmsn
 
The IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programming
The IOT Academy
 
Arduino board program for Mobile robotss
Arduino board program for Mobile robotss
VSARAVANAKUMARHICETS
 
embedded_in_Arduino_with_basic_embedded.pptx
embedded_in_Arduino_with_basic_embedded.pptx
acloudinfo2023
 
Arduino is an open-source electronics platform that has an easy-to-use physic...
Arduino is an open-source electronics platform that has an easy-to-use physic...
ssuseraa8a48
 
arduino introduction by Engr. Kennedy V. Rodriguez.pptx
arduino introduction by Engr. Kennedy V. Rodriguez.pptx
KennedyRodriguez5
 
Fundamentals of programming Arduino-Wk2.ppt
Fundamentals of programming Arduino-Wk2.ppt
ansariparveen06
 
Basic arduino components and more things about arduino
Basic arduino components and more things about arduino
GeorgeTsak
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
SAURABHKUMAR892774
 
Introduction to Arduino Programming
Introduction to Arduino Programming
James Lewis
 
ARUDINO UNO and RasberryPi with Python
ARUDINO UNO and RasberryPi with Python
Jayanthi Kannan MK
 
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.pdf
Jayanthi Kannan MK
 
introductiontoarduino-111120102058-phpapp02.pdf
introductiontoarduino-111120102058-phpapp02.pdf
HebaEng
 
Syed IoT - module 5
Syed IoT - module 5
Syed Mustafa
 
Introduction to the Arduino
Introduction to the Arduino
Wingston
 
Introduction To Arduino-converted for s.pptx
Introduction To Arduino-converted for s.pptx
rtnmsn
 
The IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programming
The IOT Academy
 
Arduino board program for Mobile robotss
Arduino board program for Mobile robotss
VSARAVANAKUMARHICETS
 
embedded_in_Arduino_with_basic_embedded.pptx
embedded_in_Arduino_with_basic_embedded.pptx
acloudinfo2023
 
Arduino is an open-source electronics platform that has an easy-to-use physic...
Arduino is an open-source electronics platform that has an easy-to-use physic...
ssuseraa8a48
 
arduino introduction by Engr. Kennedy V. Rodriguez.pptx
arduino introduction by Engr. Kennedy V. Rodriguez.pptx
KennedyRodriguez5
 
Fundamentals of programming Arduino-Wk2.ppt
Fundamentals of programming Arduino-Wk2.ppt
ansariparveen06
 
Ad

More from Amit Kumer Podder (13)

Power Amplifier
Power Amplifier
Amit Kumer Podder
 
Familiarization of electronic equipment
Familiarization of electronic equipment
Amit Kumer Podder
 
Transducer
Transducer
Amit Kumer Podder
 
Arduino Programming on Motor Control
Arduino Programming on Motor Control
Amit Kumer Podder
 
8254 Programmable Interval Timer
8254 Programmable Interval Timer
Amit Kumer Podder
 
Dot Matrix LED Interfacing using 8255 PPI
Dot Matrix LED Interfacing using 8255 PPI
Amit Kumer Podder
 
8086 Assembly Language and Serial Monitor Operation of 8086 Trainer Kit
8086 Assembly Language and Serial Monitor Operation of 8086 Trainer Kit
Amit Kumer Podder
 
8086 Micro-processor and MDA 8086 Trainer Kit
8086 Micro-processor and MDA 8086 Trainer Kit
Amit Kumer Podder
 
Traffic Light Controller using 8255
Traffic Light Controller using 8255
Amit Kumer Podder
 
8255 Programmble Peripheral Interface
8255 Programmble Peripheral Interface
Amit Kumer Podder
 
8085 Microprocessor Programming and Instruction set
8085 Microprocessor Programming and Instruction set
Amit Kumer Podder
 
Micro-processor, Micro-controller and Peripherals
Micro-processor, Micro-controller and Peripherals
Amit Kumer Podder
 
Lecture on wire splicing and termination
Lecture on wire splicing and termination
Amit Kumer Podder
 
Familiarization of electronic equipment
Familiarization of electronic equipment
Amit Kumer Podder
 
Arduino Programming on Motor Control
Arduino Programming on Motor Control
Amit Kumer Podder
 
8254 Programmable Interval Timer
8254 Programmable Interval Timer
Amit Kumer Podder
 
Dot Matrix LED Interfacing using 8255 PPI
Dot Matrix LED Interfacing using 8255 PPI
Amit Kumer Podder
 
8086 Assembly Language and Serial Monitor Operation of 8086 Trainer Kit
8086 Assembly Language and Serial Monitor Operation of 8086 Trainer Kit
Amit Kumer Podder
 
8086 Micro-processor and MDA 8086 Trainer Kit
8086 Micro-processor and MDA 8086 Trainer Kit
Amit Kumer Podder
 
Traffic Light Controller using 8255
Traffic Light Controller using 8255
Amit Kumer Podder
 
8255 Programmble Peripheral Interface
8255 Programmble Peripheral Interface
Amit Kumer Podder
 
8085 Microprocessor Programming and Instruction set
8085 Microprocessor Programming and Instruction set
Amit Kumer Podder
 
Micro-processor, Micro-controller and Peripherals
Micro-processor, Micro-controller and Peripherals
Amit Kumer Podder
 
Lecture on wire splicing and termination
Lecture on wire splicing and termination
Amit Kumer Podder
 
Ad

Recently uploaded (20)

Tally.ERP 9 at a Glance.book - Tally Solutions .pdf
Tally.ERP 9 at a Glance.book - Tally Solutions .pdf
Shabista Imam
 
How to Un-Obsolete Your Legacy Keypad Design
How to Un-Obsolete Your Legacy Keypad Design
Epec Engineered Technologies
 
Deep Learning for Image Processing on 16 June 2025 MITS.pptx
Deep Learning for Image Processing on 16 June 2025 MITS.pptx
resming1
 
Machine Learning - Classification Algorithms
Machine Learning - Classification Algorithms
resming1
 
FUNDAMENTALS OF COMPUTER ORGANIZATION AND ARCHITECTURE
FUNDAMENTALS OF COMPUTER ORGANIZATION AND ARCHITECTURE
Shabista Imam
 
Industry 4.o the fourth revolutionWeek-2.pptx
Industry 4.o the fourth revolutionWeek-2.pptx
KNaveenKumarECE
 
AI_Presentation (1). Artificial intelligence
AI_Presentation (1). Artificial intelligence
RoselynKaur8thD34
 
Validating a Citizen Observatories enabling Platform by completing a Citizen ...
Validating a Citizen Observatories enabling Platform by completing a Citizen ...
Diego López-de-Ipiña González-de-Artaza
 
Deep Learning for Natural Language Processing_FDP on 16 June 2025 MITS.pptx
Deep Learning for Natural Language Processing_FDP on 16 June 2025 MITS.pptx
resming1
 
Abraham Silberschatz-Operating System Concepts (9th,2012.12).pdf
Abraham Silberschatz-Operating System Concepts (9th,2012.12).pdf
Shabista Imam
 
Rapid Prototyping for XR: Lecture 5 - Cross Platform Development
Rapid Prototyping for XR: Lecture 5 - Cross Platform Development
Mark Billinghurst
 
System design handwritten notes guidance
System design handwritten notes guidance
Shabista Imam
 
Structured Programming with C++ :: Kjell Backman
Structured Programming with C++ :: Kjell Backman
Shabista Imam
 
MATERIAL SCIENCE LECTURE NOTES FOR DIPLOMA STUDENTS
MATERIAL SCIENCE LECTURE NOTES FOR DIPLOMA STUDENTS
SAMEER VISHWAKARMA
 
Complete University of Calculus :: 2nd edition
Complete University of Calculus :: 2nd edition
Shabista Imam
 
LECTURE 7 COMPUTATIONS OF LEVELING DATA APRIL 2025.pptx
LECTURE 7 COMPUTATIONS OF LEVELING DATA APRIL 2025.pptx
rr22001247
 
Generative AI & Scientific Research : Catalyst for Innovation, Ethics & Impact
Generative AI & Scientific Research : Catalyst for Innovation, Ethics & Impact
AlqualsaDIResearchGr
 
Fatality due to Falls at Working at Height
Fatality due to Falls at Working at Height
ssuserb8994f
 
Structural Wonderers_new and ancient.pptx
Structural Wonderers_new and ancient.pptx
nikopapa113
 
CST413 KTU S7 CSE Machine Learning Clustering K Means Hierarchical Agglomerat...
CST413 KTU S7 CSE Machine Learning Clustering K Means Hierarchical Agglomerat...
resming1
 
Tally.ERP 9 at a Glance.book - Tally Solutions .pdf
Tally.ERP 9 at a Glance.book - Tally Solutions .pdf
Shabista Imam
 
Deep Learning for Image Processing on 16 June 2025 MITS.pptx
Deep Learning for Image Processing on 16 June 2025 MITS.pptx
resming1
 
Machine Learning - Classification Algorithms
Machine Learning - Classification Algorithms
resming1
 
FUNDAMENTALS OF COMPUTER ORGANIZATION AND ARCHITECTURE
FUNDAMENTALS OF COMPUTER ORGANIZATION AND ARCHITECTURE
Shabista Imam
 
Industry 4.o the fourth revolutionWeek-2.pptx
Industry 4.o the fourth revolutionWeek-2.pptx
KNaveenKumarECE
 
AI_Presentation (1). Artificial intelligence
AI_Presentation (1). Artificial intelligence
RoselynKaur8thD34
 
Validating a Citizen Observatories enabling Platform by completing a Citizen ...
Validating a Citizen Observatories enabling Platform by completing a Citizen ...
Diego López-de-Ipiña González-de-Artaza
 
Deep Learning for Natural Language Processing_FDP on 16 June 2025 MITS.pptx
Deep Learning for Natural Language Processing_FDP on 16 June 2025 MITS.pptx
resming1
 
Abraham Silberschatz-Operating System Concepts (9th,2012.12).pdf
Abraham Silberschatz-Operating System Concepts (9th,2012.12).pdf
Shabista Imam
 
Rapid Prototyping for XR: Lecture 5 - Cross Platform Development
Rapid Prototyping for XR: Lecture 5 - Cross Platform Development
Mark Billinghurst
 
System design handwritten notes guidance
System design handwritten notes guidance
Shabista Imam
 
Structured Programming with C++ :: Kjell Backman
Structured Programming with C++ :: Kjell Backman
Shabista Imam
 
MATERIAL SCIENCE LECTURE NOTES FOR DIPLOMA STUDENTS
MATERIAL SCIENCE LECTURE NOTES FOR DIPLOMA STUDENTS
SAMEER VISHWAKARMA
 
Complete University of Calculus :: 2nd edition
Complete University of Calculus :: 2nd edition
Shabista Imam
 
LECTURE 7 COMPUTATIONS OF LEVELING DATA APRIL 2025.pptx
LECTURE 7 COMPUTATIONS OF LEVELING DATA APRIL 2025.pptx
rr22001247
 
Generative AI & Scientific Research : Catalyst for Innovation, Ethics & Impact
Generative AI & Scientific Research : Catalyst for Innovation, Ethics & Impact
AlqualsaDIResearchGr
 
Fatality due to Falls at Working at Height
Fatality due to Falls at Working at Height
ssuserb8994f
 
Structural Wonderers_new and ancient.pptx
Structural Wonderers_new and ancient.pptx
nikopapa113
 
CST413 KTU S7 CSE Machine Learning Clustering K Means Hierarchical Agglomerat...
CST413 KTU S7 CSE Machine Learning Clustering K Means Hierarchical Agglomerat...
resming1
 

Arduino Programming Familiarization

  • 1. Department of Electrical and Electronic Engineering Khulna University of Engineering & Technology Khulna-9203 Course code : EE 3214 Sessional on Microprocessors, Micro-controllers and Peripherals Presented By Amit Kumer Podder Experiment No. 09
  • 2. (a) Introduction to Arduino board and Arduino IDE (b) Design and implementation of blinking LED, analog voltage measurement, string operation and traffic controller projects in Arduino environment Experiment Name
  • 3. Arduino is a prototype platform (open-source) based on an easy- to-use hardware and software. It consists of a circuit board, which can be programed (referred to as a microcontroller) and a ready-made software called Arduino IDE (Integrated Development Environment), which is used to write and upload the computer code to the physical board. Arduino
  • 4. Arduino & Arduino Compatible Boards
  • 8. Settings: Tools  Serial Port •Your computer communicates to the Arduino microcontroller via a serial port  through a USB-Serial adapter. •Check to make sure that the drivers are properly installed.
  • 9. •Next, double-check that the proper board is selected under the ToolsBoard menu. Settings: Tools  Board
  • 10. Arduino Integrated Development Environment (IDE) Two required functions / methods / routines: void setup() { // runs once } void loop() { // repeats }error & status messages
  • 11. Comments, Comments, Comments • Comments are for you – the programmer and your friends…or anyone else human that might read your code. • // this is for single line comments • // it’s good to put a description at the top and before anything ‘tricky’ • /* this is for multi-line comments • Like this… • And this…. • */
  • 13. digitalWrite() analogWrite() digitalRead() if() statements / Boolean analogRead() Serial communication This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. BIG6CONCEPTS
  • 14. Three commands to know… • pinMode(pin, INPUT/OUTPUT); • ex: pinMode(13, OUTPUT); • digitalWrite(pin, HIGH/LOW); • ex: digitalWrite(13, HIGH); • delay(time_ms); • ex: delay(2500); // delay of 2.5 sec. • // NOTE: -> commands are CASE- sensitive
  • 15. Programming Concepts: Variables Variable Scope •Global •--- •Function-level
  • 16. Programming Concepts: Variable Types • Variable Types: 8 bits 16 bits 32 bits byte char int unsigned int long unsigned long float
  • 17. Fading in and Fading Out (Analog or Digital?) • A few pins on the Arduino allow for us to modify the output to mimic an analog signal. • This is done by a technique called: • Pulse Width Modulation (PWM)
  • 18. Concepts: Analog vs. Digital •To create an analog signal, the microcontroller uses a technique called PWM. By varying the duty cycle, we can mimic an “average” analog voltage. •Pulse Width Modulation (PWM)
  • 19. •analogWrite(pin, val); • •pin – refers to the OUTPUT pin (limited to pins 3, 5, 6, 9, 10, 11.) – denoted by a ~ symbol •val – 8 bit value (0 – 255). • 0 => 0V | 255 => 5V Introducing a new command…
  • 20. Move one of your LED pins over to Pin 9 • In Arduino, open up: • File  Examples  01.Basics  Fade
  • 21. Fade - Code Review
  • 22. Fade - Code Review
  • 25. • void loop() • { • int buttonState = digitalRead(5); • if(buttonState == LOW) • { // do something • } • else • { // do something else • } • } Programming: Conditional Statements if() DIG INPUT
  • 26. Boolean Operators <Boolean> Description ( ) == ( ) is equal? ( ) != ( ) is not equal? ( ) > ( ) greater than ( ) >= ( ) greater than or equal ( ) < ( ) less than ( ) <= ( ) less than or equal
  • 27. analogRead() • Arduino uses a 10-bit A/D Converter: • this means that you get input values from 0 to 1023 • 0 V  0 • 5 V  1023 •Ex: • int sensorValue = analogRead(A0);
  • 28. Using Serial Communication Method used to transfer data between two devices. Arduino dedicates Digital I/O pin # 0 to receiving and Digital I/O pin #1 to transmit. Data passes between the computer and Arduino through the USB cable. Data is transmitted as zeros (‘0’) and ones (‘1’) sequentially.
  • 29. Serial Monitor & analogRead() Initializes the Serial Communication 9600 baud data rate prints data to serial bus
  • 30. Serial Monitor & analogRead() Opens up a Serial Terminal Window
  • 31. Additional Serial Communication Sending a Message void loop ( ) { Serial.print(“Hands on “) ; Serial.print(“Learning ”) ; • Serial.println(“is Fun!!!”) ; }
  • 33. Serial Communication: Serial Debugging void loop() { int xVar = 10; Serial.print ( “Variable xVar is “ ) ; Serial.println ( xVar ) ; }
  • 34. Serial Communication: Serial Troubleshooting void loop ( ) { Serial.print (“Digital pin 9: “); Serial.println (digitalRead(9)); }
  • 35. Fritzing View of Breadboard Circuit •What happens when you break the circuit? •What if you wanted to add more than one LED?
  • 36. Now Let’s Play With Arduino
  • 37. Program 1 Blinking of LED void loop() { digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(13, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second } void setup() { // initialize digital pin 13 as an output. pinMode(13, OUTPUT); }