SlideShare a Scribd company logo
1 of 37
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

arduinoworkshop-160204051621.pdf
arduinoworkshop-160204051621.pdfarduinoworkshop-160204051621.pdf
arduinoworkshop-160204051621.pdfAbdErrezakChahoub
 
Introduction to Arduino Webinar
Introduction to Arduino WebinarIntroduction to Arduino Webinar
Introduction to Arduino WebinarFragiskos Fourlas
 
teststststststLecture_3_2022_Arduino.pptx
teststststststLecture_3_2022_Arduino.pptxteststststststLecture_3_2022_Arduino.pptx
teststststststLecture_3_2022_Arduino.pptxethannguyen1618
 
arduinocourse-180308074529 (1).pdf
arduinocourse-180308074529 (1).pdfarduinocourse-180308074529 (1).pdf
arduinocourse-180308074529 (1).pdfssusere5db05
 
Introduction to Arduino.pptx
Introduction to Arduino.pptxIntroduction to Arduino.pptx
Introduction to Arduino.pptxAkshat Bijronia
 
Summer training embedded system and its scope
Summer training  embedded system and its scopeSummer training  embedded system and its scope
Summer training embedded system and its scopeArshit Rai
 
Making things sense - Day 1 (May 2011)
Making things sense - Day 1 (May 2011)Making things sense - Day 1 (May 2011)
Making things sense - Day 1 (May 2011)markumoto
 
Introduction to Arduino Hardware and Programming
Introduction to Arduino Hardware and ProgrammingIntroduction to Arduino Hardware and Programming
Introduction to Arduino Hardware and ProgrammingEmmanuel Obot
 
Summer training embedded system and its scope
Summer training  embedded system and its scopeSummer training  embedded system and its scope
Summer training embedded system and its scopeArshit Rai
 
Arduino Platform with C programming.
Arduino Platform with C programming.Arduino Platform with C programming.
Arduino Platform with C programming.Govind Jha
 
isa architecture
isa architectureisa architecture
isa architectureAJAL A J
 
10 instruction sets characteristics
10 instruction sets characteristics10 instruction sets characteristics
10 instruction sets characteristicsdilip kumar
 
An Introduction to Microcontrollers.pptx
An Introduction to Microcontrollers.pptxAn Introduction to Microcontrollers.pptx
An Introduction to Microcontrollers.pptx139RAJESHA
 
Embedded system design using arduino
Embedded system design using arduinoEmbedded system design using arduino
Embedded system design using arduinoSantosh Verma
 
Arduino Programming Familiarization
Arduino Programming FamiliarizationArduino Programming Familiarization
Arduino Programming FamiliarizationAmit Kumer Podder
 

Similar to Micro_Controllers_lab1_Intro_to_Arduino.pptx (20)

arduinoworkshop-160204051621.pdf
arduinoworkshop-160204051621.pdfarduinoworkshop-160204051621.pdf
arduinoworkshop-160204051621.pdf
 
Ardui no
Ardui no Ardui no
Ardui no
 
Introduction to Arduino Webinar
Introduction to Arduino WebinarIntroduction to Arduino Webinar
Introduction to Arduino Webinar
 
arduinoedit.pptx
arduinoedit.pptxarduinoedit.pptx
arduinoedit.pptx
 
teststststststLecture_3_2022_Arduino.pptx
teststststststLecture_3_2022_Arduino.pptxteststststststLecture_3_2022_Arduino.pptx
teststststststLecture_3_2022_Arduino.pptx
 
Rig nitc [autosaved] (copy)
Rig nitc [autosaved] (copy)Rig nitc [autosaved] (copy)
Rig nitc [autosaved] (copy)
 
Arduino course
Arduino courseArduino course
Arduino course
 
arduinocourse-180308074529 (1).pdf
arduinocourse-180308074529 (1).pdfarduinocourse-180308074529 (1).pdf
arduinocourse-180308074529 (1).pdf
 
Introduction to Arduino.pptx
Introduction to Arduino.pptxIntroduction to Arduino.pptx
Introduction to Arduino.pptx
 
Summer training embedded system and its scope
Summer training  embedded system and its scopeSummer training  embedded system and its scope
Summer training embedded system and its scope
 
Making things sense - Day 1 (May 2011)
Making things sense - Day 1 (May 2011)Making things sense - Day 1 (May 2011)
Making things sense - Day 1 (May 2011)
 
Introduction to Arduino Hardware and Programming
Introduction to Arduino Hardware and ProgrammingIntroduction to Arduino Hardware and Programming
Introduction to Arduino Hardware and Programming
 
Summer training embedded system and its scope
Summer training  embedded system and its scopeSummer training  embedded system and its scope
Summer training embedded system and its scope
 
Arduino Platform with C programming.
Arduino Platform with C programming.Arduino Platform with C programming.
Arduino Platform with C programming.
 
isa architecture
isa architectureisa architecture
isa architecture
 
10 instruction sets characteristics
10 instruction sets characteristics10 instruction sets characteristics
10 instruction sets characteristics
 
intro_mcu.pdf
intro_mcu.pdfintro_mcu.pdf
intro_mcu.pdf
 
An Introduction to Microcontrollers.pptx
An Introduction to Microcontrollers.pptxAn Introduction to Microcontrollers.pptx
An Introduction to Microcontrollers.pptx
 
Embedded system design using arduino
Embedded system design using arduinoEmbedded system design using arduino
Embedded system design using arduino
 
Arduino Programming Familiarization
Arduino Programming FamiliarizationArduino Programming Familiarization
Arduino Programming Familiarization
 

Recently uploaded

Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
EduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIEduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIkoyaldeepu123
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture designssuser87fa0c1
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 

Recently uploaded (20)

Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
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
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
EduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIEduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AI
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture design
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 

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

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