SlideShare a Scribd company logo
ARDUINO – LAB1
AGENDA
• Micro processors VS Micro-Controllers
• Arduino Boards
• Digital I/O Pins
• IDE & Software Development
• Timing
Micro processor
• an IC which has only the CPU inside
• Examples : Intel’s Pentium 1,2,3,4, core 2 duo, i3,
i5 etc
• doesn’t have RAM, ROM, and other peripherals
on the chip.
• Used in applications where tasks are unspecific
like developing software, games, websites, photo
editing, creating documents
Micro controller
• Has a CPU, in addition with a fixed amount of RAM, ROM and other
peripherals all embedded on a single chip.
• Sometimes called computers on chip.
• are designed to perform specific tasks.
• For example, keyboards, mouse, washing machine, remote,
microwave, cars, bikes, telephone, mobiles and watches.
MICRO-CONTROLLERS
Arduino and Microcontroller
Atmega328p
• A microcontroller created by Atmel
• in the megaAVR family
• Has a modified Harvard architecture 8-
bit RISC processor core.
• 32 KB ISP flash memory
• 32 general purpose working registers
• …. and many other things
Why ?!
Do you remember this ???
What if we can replace them all in one chip???
=
ARDUINO BOARD
• Ready to use Board
• Atmega µC
• Plug-n-Play
• Open Source
• Arduino language is based on c and c++ [reference provided]
• Large Community
ARDUINO BOARD COMPONENTS
• Power Circuit
• Digital Pins
• Analog Pins
• Serial Protocols
• USB Interface
ARDUINO UNO BOARD
BUT BEHIND THIS ….
Digital input Output
ATMEGA
ATMEGA
ATMEGA
MAPPING BETWEEN ATMEGA AND
ARDUINO UNO I/O PINS
INSTALL THE ARDUINO IDE
• Download from
www.arduino.cc
• Free
• Easy to Use
• Code & Upload
ARDUINO IDE
• Sketch
• Arduino Project
• Setup
• Runs at Start-up (1 time)
• Initialization
• Loop
• Runs after “Setup”
• Program Logic
• Runs forever
ARDUINO LANGUAGE
• Embedded C (Similar to C++)
• Data types (int, float, char, …)
• Functions
• Conditional statements (If … else)
• Loop statements (for / while)
• Use Libraries (math, string, …)
• New Functions & Libraries
• Deal with I/O Ports
• Protocols
ARDUINO LANGUAGE
• Data types:
• boolean val = false ;
• Char chr_a = ‘a’;
• Char chr_c = 97 ;
• byte m = 25 ;
• int counter = 32 ;
• Unsigned int counter = 60 ;
• word w = 1000 ;
• Long velocity = 102346 ;
• short val = 13 ;
• float num = 1.352;
• double num = 45.352 ;
ARDUINO LANGUAGE
• Data types ( char arrays)
• char like[] = "I like coffee and cake"; // create a string
• like[12] = 't’;
• char str[40];
• num = strlen(str); // get the length of the string (excludes null terminator)
• All the string c library applies here.
• We can define arrays with other datatypes.
ARDUINO LANGUAGE
• Variable scopes:
• Local variables
• Global variables: available for use throughout your entire program after its
declaration.
• example
Int T , S ;
float c = 0 ; Global variable declaration
Void setup () {
}
ARDUINO LANGUAGE
• Operators:
• Arithmetic (+,-,*,/,%,=)
• Comparison (==, !=,<,>,<=,>=)
• Boolean ( &&,||,! )
• Bitwise (&,|,^,~,<<,>>)
• Compound ( +=, -= , …. )
ARDUINO LANGUAGE
• Control statements:
• If else is example:
if (expression_1) {
Block of statements;
}
else if(expression_2) {
Block of statements;
}
.
.
.
else {
Block of statements;
}
ARDUINO LANGUAGE
• Debugging:
• Open the serial monitor
Void setup() {
Serial.begin(9600);
// send data only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
char str[] = "This is my string"; // create a string
Serial.print("String length is: ");
Serial.println(str);
}
DIGITAL I/O PINS
• Digital Pin could work as
• Input
• Output
• Special Functionality
• Functions we may use
• pinMode(pin_num, mode) //mode=INPUT/OUTPUT
• digitalWrite(pin_num, value) //value=HIGH/LOW
• value = digitalRead(pin_num)
• delay(50) ; the time is measured in milliseconds
• Write Arduino code that sums the elements in array of
10 integers defined as a global variable integer array
[87, 68, 94, 100, 83, 78, 85, 91, 76, 87 ]
• Make each loop print to the serial one integer only
• Make a delay of 0.5 second between each print
• Print every integer in a new line
Ex1
BASIC CIRCUITS (LEDS)
• Connecting LEDs
• A typical Red LED has a voltage drop
of 1.8 V and a current of about 25mA
and the Arduino Pin has an output of 5V.
Using these values,
the resistor calculation is:
V = (power source) - (Voltage Drop)
= 5V - 1.8V = 3.2 V
, I = 25 mA
, R = V/I
so R = 3.2/0.025 = 128 Ohms.
3.2 volt ,25 mA and 128ohm
1.8 volt and 25mA
BASIC CIRCUITS (MULTIPLE BOARDS)
• Common Ground
Compiling and
uploading
FUNCTIONS TO USE
• pinMode(pin, INPUT/OUTPUT);
• digitalWrite(pin, HIGH/LOW);
• delay(time_ms);
TIMING
• We need to make delays
• Arduino has different Timing Functions
• delay(ms_time)
• delayMicroseconds(µs_time)
• millis()
• Returns the num of milliseconds from start of Arduino
• micros()
• Returns the num of microseconds from start of Arduino
• Value depends on Arduino Freq
EXERCISE TIME
• Connect a button to pin
2
• An onboard LED is
attached to pin 13
• Ex2)
• the blinking LED Example
• LED (on) for 1 sec then
(off) for 1 sec
• Ex3)
Write a LED on/off program
• Button Pressed -> LED on
• Button Released -> LED off
• EX2)
• Write a LED toggle program
• Button Pressed -> Toggle LED
state
• The led is initially off.
Thanks !

More Related Content

Similar to Micro_Controllers_lab1_Intro_to_Arduino.pptx (20)

Arduino Programming - Brief Introduction
Arduino Programming - Brief IntroductionArduino Programming - Brief Introduction
Arduino Programming - Brief Introduction
NEEVEE Technologies
 
01 Intro to the Arduino and it's basics.ppt
01 Intro to the Arduino and it's basics.ppt01 Intro to the Arduino and it's basics.ppt
01 Intro to the Arduino and it's basics.ppt
pindi2197
 
Arduino
ArduinoArduino
Arduino
LetzkuLetz Castro
 
Arduino Platform with C programming.
Arduino Platform with C programming.Arduino Platform with C programming.
Arduino Platform with C programming.
Govind Jha
 
Arduino reference
Arduino referenceArduino reference
Arduino reference
Marcos Henrique
 
13223971.ppt
13223971.ppt13223971.ppt
13223971.ppt
SuYee13
 
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
SAURABHKUMAR892774
 
Ardui no
Ardui no Ardui no
Ardui no
Amol Sakhalkar
 
arduinoworkshop-160204051621.pdf
arduinoworkshop-160204051621.pdfarduinoworkshop-160204051621.pdf
arduinoworkshop-160204051621.pdf
AbdErrezakChahoub
 
Introduction to Arduino Microcontroller
Introduction to Arduino MicrocontrollerIntroduction to Arduino Microcontroller
Introduction to Arduino Microcontroller
Mujahid Hussain
 
Arduino by yogesh t s'
Arduino by yogesh t s'Arduino by yogesh t s'
Arduino by yogesh t s'
tsyogesh46
 
Chapter 5 Arduino Microcontroller Systems .pptx
Chapter 5 Arduino Microcontroller Systems .pptxChapter 5 Arduino Microcontroller Systems .pptx
Chapter 5 Arduino Microcontroller Systems .pptx
khgh7
 
Basics of open source embedded development board (
Basics of open source embedded development board (Basics of open source embedded development board (
Basics of open source embedded development board (
Dhruwank Vankawala
 
Basics of open source embedded development board (
Basics of open source embedded development board (Basics of open source embedded development board (
Basics of open source embedded development board (
Dhruwank Vankawala
 
Starting with Arduino
Starting with Arduino Starting with Arduino
Starting with Arduino
MajdyShamasneh
 
Arduino . .
Arduino             .                             .Arduino             .                             .
Arduino . .
dryazhinians
 
Introduction to Arduino Hardware and Programming
Introduction to Arduino Hardware and ProgrammingIntroduction to Arduino Hardware and Programming
Introduction to Arduino Hardware and Programming
Emmanuel Obot
 
How to use an Arduino
How to use an ArduinoHow to use an Arduino
How to use an Arduino
AntonAndreev13
 
arduinocourse-180308074529 (1).pdf
arduinocourse-180308074529 (1).pdfarduinocourse-180308074529 (1).pdf
arduinocourse-180308074529 (1).pdf
ssusere5db05
 
Arduino Labs Introduction
Arduino Labs IntroductionArduino Labs Introduction
Arduino Labs Introduction
Open.Embedded
 
Arduino Programming - Brief Introduction
Arduino Programming - Brief IntroductionArduino Programming - Brief Introduction
Arduino Programming - Brief Introduction
NEEVEE Technologies
 
01 Intro to the Arduino and it's basics.ppt
01 Intro to the Arduino and it's basics.ppt01 Intro to the Arduino and it's basics.ppt
01 Intro to the Arduino and it's basics.ppt
pindi2197
 
Arduino Platform with C programming.
Arduino Platform with C programming.Arduino Platform with C programming.
Arduino Platform with C programming.
Govind Jha
 
13223971.ppt
13223971.ppt13223971.ppt
13223971.ppt
SuYee13
 
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
SAURABHKUMAR892774
 
arduinoworkshop-160204051621.pdf
arduinoworkshop-160204051621.pdfarduinoworkshop-160204051621.pdf
arduinoworkshop-160204051621.pdf
AbdErrezakChahoub
 
Introduction to Arduino Microcontroller
Introduction to Arduino MicrocontrollerIntroduction to Arduino Microcontroller
Introduction to Arduino Microcontroller
Mujahid Hussain
 
Arduino by yogesh t s'
Arduino by yogesh t s'Arduino by yogesh t s'
Arduino by yogesh t s'
tsyogesh46
 
Chapter 5 Arduino Microcontroller Systems .pptx
Chapter 5 Arduino Microcontroller Systems .pptxChapter 5 Arduino Microcontroller Systems .pptx
Chapter 5 Arduino Microcontroller Systems .pptx
khgh7
 
Basics of open source embedded development board (
Basics of open source embedded development board (Basics of open source embedded development board (
Basics of open source embedded development board (
Dhruwank Vankawala
 
Basics of open source embedded development board (
Basics of open source embedded development board (Basics of open source embedded development board (
Basics of open source embedded development board (
Dhruwank Vankawala
 
Starting with Arduino
Starting with Arduino Starting with Arduino
Starting with Arduino
MajdyShamasneh
 
Introduction to Arduino Hardware and Programming
Introduction to Arduino Hardware and ProgrammingIntroduction to Arduino Hardware and Programming
Introduction to Arduino Hardware and Programming
Emmanuel Obot
 
arduinocourse-180308074529 (1).pdf
arduinocourse-180308074529 (1).pdfarduinocourse-180308074529 (1).pdf
arduinocourse-180308074529 (1).pdf
ssusere5db05
 
Arduino Labs Introduction
Arduino Labs IntroductionArduino Labs Introduction
Arduino Labs Introduction
Open.Embedded
 

Recently uploaded (20)

Water demand - Types , variations and WDS
Water demand - Types , variations and WDSWater demand - Types , variations and WDS
Water demand - Types , variations and WDS
dhanashree78
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
djiceramil
 
Center Enamel can Provide Aluminum Dome Roofs for diesel tank.docx
Center Enamel can Provide Aluminum Dome Roofs for  diesel tank.docxCenter Enamel can Provide Aluminum Dome Roofs for  diesel tank.docx
Center Enamel can Provide Aluminum Dome Roofs for diesel tank.docx
CenterEnamel
 
最新版美国圣莫尼卡学院毕业证(SMC毕业证书)原版定制
最新版美国圣莫尼卡学院毕业证(SMC毕业证书)原版定制最新版美国圣莫尼卡学院毕业证(SMC毕业证书)原版定制
最新版美国圣莫尼卡学院毕业证(SMC毕业证书)原版定制
Taqyea
 
First Come First Serve Scheduling in real time operating system.pptx
First Come First Serve Scheduling in real time operating system.pptxFirst Come First Serve Scheduling in real time operating system.pptx
First Come First Serve Scheduling in real time operating system.pptx
KavitaBagewadi2
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
djiceramil
 
David Boutry - Mentors Junior Developers
David Boutry - Mentors Junior DevelopersDavid Boutry - Mentors Junior Developers
David Boutry - Mentors Junior Developers
David Boutry
 
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
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
djiceramil
 
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptxFINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
kippcam
 
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Rearchitecturing a 9-year-old legacy Laravel application.pdfRearchitecturing a 9-year-old legacy Laravel application.pdf
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Takumi Amitani
 
OCS Group SG - HPHT Well Design and Operation - SN.pdf
OCS Group SG - HPHT Well Design and Operation - SN.pdfOCS Group SG - HPHT Well Design and Operation - SN.pdf
OCS Group SG - HPHT Well Design and Operation - SN.pdf
Muanisa Waras
 
Great power lithium iron phosphate cells
Great power lithium iron phosphate cellsGreat power lithium iron phosphate cells
Great power lithium iron phosphate cells
salmankhan835951
 
Blood bank management system project report.pdf
Blood bank management system project report.pdfBlood bank management system project report.pdf
Blood bank management system project report.pdf
Kamal Acharya
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
djiceramil
 
Flow Chart Proses Bisnis prosscesss.docx
Flow Chart Proses Bisnis prosscesss.docxFlow Chart Proses Bisnis prosscesss.docx
Flow Chart Proses Bisnis prosscesss.docx
rifka575530
 
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) ProjectMontreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Alexandra N. Martinez
 
NALCO Green Anode Plant,Compositions of CPC,Pitch
NALCO Green Anode Plant,Compositions of CPC,PitchNALCO Green Anode Plant,Compositions of CPC,Pitch
NALCO Green Anode Plant,Compositions of CPC,Pitch
arpitprachi123
 
4th International Conference on Computer Science and Information Technology (...
4th International Conference on Computer Science and Information Technology (...4th International Conference on Computer Science and Information Technology (...
4th International Conference on Computer Science and Information Technology (...
ijait
 
Decoding Kotlin - Your Guide to Solving the Mysterious in Kotlin - Devoxx PL ...
Decoding Kotlin - Your Guide to Solving the Mysterious in Kotlin - Devoxx PL ...Decoding Kotlin - Your Guide to Solving the Mysterious in Kotlin - Devoxx PL ...
Decoding Kotlin - Your Guide to Solving the Mysterious in Kotlin - Devoxx PL ...
João Esperancinha
 
Water demand - Types , variations and WDS
Water demand - Types , variations and WDSWater demand - Types , variations and WDS
Water demand - Types , variations and WDS
dhanashree78
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
djiceramil
 
Center Enamel can Provide Aluminum Dome Roofs for diesel tank.docx
Center Enamel can Provide Aluminum Dome Roofs for  diesel tank.docxCenter Enamel can Provide Aluminum Dome Roofs for  diesel tank.docx
Center Enamel can Provide Aluminum Dome Roofs for diesel tank.docx
CenterEnamel
 
最新版美国圣莫尼卡学院毕业证(SMC毕业证书)原版定制
最新版美国圣莫尼卡学院毕业证(SMC毕业证书)原版定制最新版美国圣莫尼卡学院毕业证(SMC毕业证书)原版定制
最新版美国圣莫尼卡学院毕业证(SMC毕业证书)原版定制
Taqyea
 
First Come First Serve Scheduling in real time operating system.pptx
First Come First Serve Scheduling in real time operating system.pptxFirst Come First Serve Scheduling in real time operating system.pptx
First Come First Serve Scheduling in real time operating system.pptx
KavitaBagewadi2
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
djiceramil
 
David Boutry - Mentors Junior Developers
David Boutry - Mentors Junior DevelopersDavid Boutry - Mentors Junior Developers
David Boutry - Mentors Junior Developers
David Boutry
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
djiceramil
 
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptxFINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
kippcam
 
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Rearchitecturing a 9-year-old legacy Laravel application.pdfRearchitecturing a 9-year-old legacy Laravel application.pdf
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Takumi Amitani
 
OCS Group SG - HPHT Well Design and Operation - SN.pdf
OCS Group SG - HPHT Well Design and Operation - SN.pdfOCS Group SG - HPHT Well Design and Operation - SN.pdf
OCS Group SG - HPHT Well Design and Operation - SN.pdf
Muanisa Waras
 
Great power lithium iron phosphate cells
Great power lithium iron phosphate cellsGreat power lithium iron phosphate cells
Great power lithium iron phosphate cells
salmankhan835951
 
Blood bank management system project report.pdf
Blood bank management system project report.pdfBlood bank management system project report.pdf
Blood bank management system project report.pdf
Kamal Acharya
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
djiceramil
 
Flow Chart Proses Bisnis prosscesss.docx
Flow Chart Proses Bisnis prosscesss.docxFlow Chart Proses Bisnis prosscesss.docx
Flow Chart Proses Bisnis prosscesss.docx
rifka575530
 
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) ProjectMontreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Alexandra N. Martinez
 
NALCO Green Anode Plant,Compositions of CPC,Pitch
NALCO Green Anode Plant,Compositions of CPC,PitchNALCO Green Anode Plant,Compositions of CPC,Pitch
NALCO Green Anode Plant,Compositions of CPC,Pitch
arpitprachi123
 
4th International Conference on Computer Science and Information Technology (...
4th International Conference on Computer Science and Information Technology (...4th International Conference on Computer Science and Information Technology (...
4th International Conference on Computer Science and Information Technology (...
ijait
 
Decoding Kotlin - Your Guide to Solving the Mysterious in Kotlin - Devoxx PL ...
Decoding Kotlin - Your Guide to Solving the Mysterious in Kotlin - Devoxx PL ...Decoding Kotlin - Your Guide to Solving the Mysterious in Kotlin - Devoxx PL ...
Decoding Kotlin - Your Guide to Solving the Mysterious in Kotlin - Devoxx PL ...
João Esperancinha
 
Ad

Micro_Controllers_lab1_Intro_to_Arduino.pptx

  • 2. AGENDA • Micro processors VS Micro-Controllers • Arduino Boards • Digital I/O Pins • IDE & Software Development • Timing
  • 3. Micro processor • an IC which has only the CPU inside • Examples : Intel’s Pentium 1,2,3,4, core 2 duo, i3, i5 etc • doesn’t have RAM, ROM, and other peripherals on the chip. • Used in applications where tasks are unspecific like developing software, games, websites, photo editing, creating documents
  • 4. Micro controller • Has a CPU, in addition with a fixed amount of RAM, ROM and other peripherals all embedded on a single chip. • Sometimes called computers on chip. • are designed to perform specific tasks. • For example, keyboards, mouse, washing machine, remote, microwave, cars, bikes, telephone, mobiles and watches.
  • 6. Arduino and Microcontroller Atmega328p • A microcontroller created by Atmel • in the megaAVR family • Has a modified Harvard architecture 8- bit RISC processor core. • 32 KB ISP flash memory • 32 general purpose working registers • …. and many other things
  • 8. Do you remember this ???
  • 9. What if we can replace them all in one chip???
  • 10. =
  • 11. ARDUINO BOARD • Ready to use Board • Atmega µC • Plug-n-Play • Open Source • Arduino language is based on c and c++ [reference provided] • Large Community
  • 12. ARDUINO BOARD COMPONENTS • Power Circuit • Digital Pins • Analog Pins • Serial Protocols • USB Interface
  • 19. MAPPING BETWEEN ATMEGA AND ARDUINO UNO I/O PINS
  • 20. INSTALL THE ARDUINO IDE • Download from www.arduino.cc • Free • Easy to Use • Code & Upload
  • 21. ARDUINO IDE • Sketch • Arduino Project • Setup • Runs at Start-up (1 time) • Initialization • Loop • Runs after “Setup” • Program Logic • Runs forever
  • 22. ARDUINO LANGUAGE • Embedded C (Similar to C++) • Data types (int, float, char, …) • Functions • Conditional statements (If … else) • Loop statements (for / while) • Use Libraries (math, string, …) • New Functions & Libraries • Deal with I/O Ports • Protocols
  • 23. ARDUINO LANGUAGE • Data types: • boolean val = false ; • Char chr_a = ‘a’; • Char chr_c = 97 ; • byte m = 25 ; • int counter = 32 ; • Unsigned int counter = 60 ; • word w = 1000 ; • Long velocity = 102346 ; • short val = 13 ; • float num = 1.352; • double num = 45.352 ;
  • 24. ARDUINO LANGUAGE • Data types ( char arrays) • char like[] = "I like coffee and cake"; // create a string • like[12] = 't’; • char str[40]; • num = strlen(str); // get the length of the string (excludes null terminator) • All the string c library applies here. • We can define arrays with other datatypes.
  • 25. ARDUINO LANGUAGE • Variable scopes: • Local variables • Global variables: available for use throughout your entire program after its declaration. • example Int T , S ; float c = 0 ; Global variable declaration Void setup () { }
  • 26. ARDUINO LANGUAGE • Operators: • Arithmetic (+,-,*,/,%,=) • Comparison (==, !=,<,>,<=,>=) • Boolean ( &&,||,! ) • Bitwise (&,|,^,~,<<,>>) • Compound ( +=, -= , …. )
  • 27. ARDUINO LANGUAGE • Control statements: • If else is example: if (expression_1) { Block of statements; } else if(expression_2) { Block of statements; } . . . else { Block of statements; }
  • 28. ARDUINO LANGUAGE • Debugging: • Open the serial monitor Void setup() { Serial.begin(9600); // send data only when you receive data: if (Serial.available() > 0) { // read the incoming byte: incomingByte = Serial.read(); char str[] = "This is my string"; // create a string Serial.print("String length is: "); Serial.println(str); }
  • 29. DIGITAL I/O PINS • Digital Pin could work as • Input • Output • Special Functionality • Functions we may use • pinMode(pin_num, mode) //mode=INPUT/OUTPUT • digitalWrite(pin_num, value) //value=HIGH/LOW • value = digitalRead(pin_num) • delay(50) ; the time is measured in milliseconds
  • 30. • Write Arduino code that sums the elements in array of 10 integers defined as a global variable integer array [87, 68, 94, 100, 83, 78, 85, 91, 76, 87 ] • Make each loop print to the serial one integer only • Make a delay of 0.5 second between each print • Print every integer in a new line Ex1
  • 31. BASIC CIRCUITS (LEDS) • Connecting LEDs • A typical Red LED has a voltage drop of 1.8 V and a current of about 25mA and the Arduino Pin has an output of 5V. Using these values, the resistor calculation is: V = (power source) - (Voltage Drop) = 5V - 1.8V = 3.2 V , I = 25 mA , R = V/I so R = 3.2/0.025 = 128 Ohms. 3.2 volt ,25 mA and 128ohm 1.8 volt and 25mA
  • 32. BASIC CIRCUITS (MULTIPLE BOARDS) • Common Ground
  • 34. FUNCTIONS TO USE • pinMode(pin, INPUT/OUTPUT); • digitalWrite(pin, HIGH/LOW); • delay(time_ms);
  • 35. TIMING • We need to make delays • Arduino has different Timing Functions • delay(ms_time) • delayMicroseconds(µs_time) • millis() • Returns the num of milliseconds from start of Arduino • micros() • Returns the num of microseconds from start of Arduino • Value depends on Arduino Freq
  • 36. EXERCISE TIME • Connect a button to pin 2 • An onboard LED is attached to pin 13 • Ex2) • the blinking LED Example • LED (on) for 1 sec then (off) for 1 sec • Ex3) Write a LED on/off program • Button Pressed -> LED on • Button Released -> LED off • EX2) • Write a LED toggle program • Button Pressed -> Toggle LED state • The led is initially off.

Editor's Notes

  • #35: “B” for Binary, “1”-> output, “0”-> Input If we want another port?
  • #47: Mode & Value are enums, we could use 0 & 1 instead
  • #53: What are the max delay that can be generated?, If we want a delay in days how to make it?