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)

PPTX
Arduino Programming - Brief Introduction
NEEVEE Technologies
 
PPT
01 Intro to the Arduino and it's basics.ppt
pindi2197
 
PPTX
Arduino
LetzkuLetz Castro
 
PPT
Arduino Platform with C programming.
Govind Jha
 
PDF
Arduino reference
Marcos Henrique
 
PPT
13223971.ppt
SuYee13
 
PPT
Arduino_CSE ece ppt for working and principal of arduino.ppt
SAURABHKUMAR892774
 
PPTX
Ardui no
Amol Sakhalkar
 
PDF
arduinoworkshop-160204051621.pdf
AbdErrezakChahoub
 
PPTX
Introduction to Arduino Microcontroller
Mujahid Hussain
 
PPSX
Arduino by yogesh t s'
tsyogesh46
 
PPTX
Chapter 5 Arduino Microcontroller Systems .pptx
khgh7
 
PPTX
Basics of open source embedded development board (
Dhruwank Vankawala
 
PPTX
Basics of open source embedded development board (
Dhruwank Vankawala
 
PDF
Starting with Arduino
MajdyShamasneh
 
PPTX
Arduino . .
dryazhinians
 
PPTX
Introduction to Arduino Hardware and Programming
Emmanuel Obot
 
PPTX
How to use an Arduino
AntonAndreev13
 
PDF
arduinocourse-180308074529 (1).pdf
ssusere5db05
 
PDF
Arduino Labs Introduction
Open.Embedded
 
Arduino Programming - Brief Introduction
NEEVEE Technologies
 
01 Intro to the Arduino and it's basics.ppt
pindi2197
 
Arduino Platform with C programming.
Govind Jha
 
Arduino reference
Marcos Henrique
 
13223971.ppt
SuYee13
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
SAURABHKUMAR892774
 
Ardui no
Amol Sakhalkar
 
arduinoworkshop-160204051621.pdf
AbdErrezakChahoub
 
Introduction to Arduino Microcontroller
Mujahid Hussain
 
Arduino by yogesh t s'
tsyogesh46
 
Chapter 5 Arduino Microcontroller Systems .pptx
khgh7
 
Basics of open source embedded development board (
Dhruwank Vankawala
 
Basics of open source embedded development board (
Dhruwank Vankawala
 
Starting with Arduino
MajdyShamasneh
 
Arduino . .
dryazhinians
 
Introduction to Arduino Hardware and Programming
Emmanuel Obot
 
How to use an Arduino
AntonAndreev13
 
arduinocourse-180308074529 (1).pdf
ssusere5db05
 
Arduino Labs Introduction
Open.Embedded
 

Recently uploaded (20)

PPTX
Knowledge Representation : Semantic Networks
Amity University, Patna
 
PDF
Digital water marking system project report
Kamal Acharya
 
PPT
New_school_Engineering_presentation_011707.ppt
VinayKumar304579
 
PPTX
澳洲电子毕业证澳大利亚圣母大学水印成绩单UNDA学生证网上可查学历
Taqyea
 
PDF
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
PPTX
OCS353 DATA SCIENCE FUNDAMENTALS- Unit 1 Introduction to Data Science
A R SIVANESH M.E., (Ph.D)
 
PPTX
darshai cross section and river section analysis
muk7971
 
PPTX
Introduction to Internal Combustion Engines - Types, Working and Camparison.pptx
UtkarshPatil98
 
PDF
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
PDF
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
PPTX
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
PPTX
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
PDF
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
PDF
Bachelor of information technology syll
SudarsanAssistantPro
 
PPTX
仿制LethbridgeOffer加拿大莱斯桥大学毕业证范本,Lethbridge成绩单
Taqyea
 
PDF
mbse_An_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PDF
3rd International Conference on Machine Learning and IoT (MLIoT 2025)
ClaraZara1
 
PDF
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
PDF
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
Knowledge Representation : Semantic Networks
Amity University, Patna
 
Digital water marking system project report
Kamal Acharya
 
New_school_Engineering_presentation_011707.ppt
VinayKumar304579
 
澳洲电子毕业证澳大利亚圣母大学水印成绩单UNDA学生证网上可查学历
Taqyea
 
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
OCS353 DATA SCIENCE FUNDAMENTALS- Unit 1 Introduction to Data Science
A R SIVANESH M.E., (Ph.D)
 
darshai cross section and river section analysis
muk7971
 
Introduction to Internal Combustion Engines - Types, Working and Camparison.pptx
UtkarshPatil98
 
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
Bachelor of information technology syll
SudarsanAssistantPro
 
仿制LethbridgeOffer加拿大莱斯桥大学毕业证范本,Lethbridge成绩单
Taqyea
 
mbse_An_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
3rd International Conference on Machine Learning and IoT (MLIoT 2025)
ClaraZara1
 
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
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?