SlideShare a Scribd company logo
Lab 2: Arduino
Zhentao Xu
Today’s schedule
• Lecture 1: Arduino
• Install Arduino driver
• Lab 1: use Arduino UNO to control LED.
• Lecture 2: Sensor and Feedback
• Lab 2: use Arduino UNO and ultrasonic distance
sensor to measure distance
• Lecture 3: Minimum system
• Lab 3: Building minimum system using AVR chip.
What is Arduino?
• Official definition: A combination of hardware,
software, development team, design philosophy.
• From Ivrea, Italy.(意大利的艾维里)
• Hardware include Arduino UNO and Arduino Mega,
Software include Arduino IDE.
• Arduino UNO: Development board of AVR chips.
• Arduino UNO is announced in 2011.
• UNO Punto Zero (1.0)
What can Arduino UNO do?
Self-balanced Car
What can Arduino UNO do?
LED-Cubic
Arduino Components
Processor
USB
Ports
Power
Supply power &
Serial Communicate
Connection with outside
world
Supply power
Process information &
Make decision
Real Circuit Diagram
Install Arduino driver
Refer to the PDF file from the announcement on SAKAI.
For Windows 7 Operating Systen:
• Step 1: Download Arduino IDE and unzip it.
• http://arduino.googlecode.com/files/arduino-1.0.5-r2-
windows.zip
• Step 2: Plug in Arduino UNO board.
• Step 3: Right-click This PC  Manage Other
device Right-click Unknown deviceUpdate
driver Scan the driver folder in Arduino IDE.
For Windows 8/8.1, please refer to PDF file.
For Mac OS/Linux, Skip this slides.
Arduino IDE
Arduino IDE
• An integrated development environment designed
for Arduino hardware.
• The language is C++ - like.
• Process of doing Arduino Project:
• Connect hardware with Arduino UNO
• Write program on Arduino IDE.
• Download it onto Arduino UNO.
• Power Arduino UNO on and enjoy it.
Arduino IDE
• Structure: two necessary functions:
1. void setup(){}
2. void loop(){}
• The relationship between Arduino Language and
C++ Language.
• Important sentence:
pinMode (PinNumber,Mode); (general in setup(){};)
digitalWrite (PinNumber, DigitalVoltage);
delay (MiliSeconds);
Lab #1: Light up LED
• Requirement:
• Light up LED and keep 3 seconds, than power it off and
keep 3 seconds.
• Repeat the procedure.
• DIY
Quite easy, right?
void setup()
{
//Connect LED resistor on pin 13.
pinMode(13,OUTPUT);
}
void loop()
{
digitalWrite(13,HIGH);
delay(5000);
digitalWrite(13,LOW);
delay(5000);
}
Quick Review
• You have controlled the On and Off of LED by
control the output voltage of a certain port.
• The voltage on pin 13 is called digital signal, which
can be either 1 (logical-high voltage) or 0 (logical-
low voltage).
• Actually, Arduino UNO can output/input
digital/analog signals.
Sensor(传感器)
• Arduino is like a brain. It also needs ears, eyes, nose,
etc. to measure quantities in outside environment.
• Sensor serves as the connection between Arduino
and the outside environment.
• So called Feed back control
Temp. Sound
Light …
Environment
Velocity Sensor -- Tachometer
Velocity sensor –
Tachometers
Where K is the back EMF
constant.
Every car has a tachometer
so as to measurer to measure
speed.
(t) K (t)t vwV 
Temperature Sensor
• Three classes f temperature sensors:
• Thermometers and bimetallic strips ---- Sensors which
change physical dimension as a function of temperature.
• RTDs and thermistors ----Sensors which change
resistance as a function of temperature.
• RTD:
• Thermistor:
• Thermocouples ----Sensors which work based on
thermoelectric phenomena
0 0(1 (T T ))R R   
0
1 1
( )
0
T T
R R e
 

Ultrasonic sensor
• Ultrasonic sensors are used to measure distance.
• An impulse of ultrasonic wave is emitted from the
sensor. The wave will reflect when reaches some
obstacles. The time between emission and
receiving will be calculated.
• Use formula to calculate the
distance.
/ 2L Vt
HC-SR04 ultrasonic sensor
• Four pins (GND, VCC, Trig, Echo)
• GND and VCC is the power supply to this module.
• Arduino UNO send message to Trig, and read
message from Echo.
Serial Ports (COM,串口)
Communication
• Serial is one way in which information is transferred
between computer & Arduino.
• Information can also be transferred using Parallel
Ports.(并口)
• Two important sentence of serial communication.
• Serial.begin(BaudRate); (must be in setup())
• Serial.write(message);
Lab 2: Use ultrasonic sensor to
measure distance
Electronic components Number Note
Arduino UNO 1 With USB wire
HC-SR04 Sensor 1
Wires 4
Arduino UNO HC-SR04 Note
GND GND
VCC VCC
A1 (Pin 15) Trig
A0(Pin 14) Echo
Lab equipment:
Wire connection
Program
void loop()
{
digitalWrite(TrigPin, LOW);
delayMicroseconds(2);
digitalWrite(TrigPin, HIGH);
delayMicroseconds(5);
digitalWrite(TrigPin, LOW);
cm = int(pulseIn(EchoPin, HIGH) / 58.0);
Serial.println(cm);
}
const int TrigPin = 15;
const int EchoPin = 14;
float cm;
void setup()
{
Serial.begin(9600);
pinMode(TrigPin, OUTPUT);
pinMode(EchoPin, INPUT);
}
Quick Review
• Sensor: connection between Arduino and outside
environment.
• Serial: one way in which information is transferred.
AVR
• AVR is a family of MCU chips which are produced
by ATMEL Company.
• The AVR chip on Arduino UNO is Atmega328.
• The AVR chip on Arduino MEGA is Atmega2560
• Working environment:
• Stable 5V power supply
• Time reference input
• (RESET)
Atmega328P-PU
• Pin number and
counting order.
• Significant pin for
working.
• Power supply: PIN7,
PIN8, PIN20, PIN22.
• RESET: PIN1
• Timing: PIN9,
PIN10
• Serial Ports: PIN2,
PIN3
Min. Sys. Of Atmega328P-PU
• Minimum system: MCU chip with simplest
peripheral circuit. (外围电路).
• Below is the circuit for min. sys. of Atmega328P.
Lab 3: Min. Sys. Of Atmega328P
• Step 1 Remove the MCU chip on Arduino.
Step 2. Build the minimum system
Step 3 Connect LED and
download program
• Connect the series of LED and resistor to pin GND
and pin 19.
• Connect the Arduino PCB and your computer as is
done in Lab 1.
• Write exactly the same program as in Lab 1 without
any change.
• Click the Download button.
• See what happen~~^_^
Step 3 Connect LED and
download program
• When the download process has been down, you
can remove the RESET line and RX TX line, just
leaving the VCC and GND so as to give power to the
Atmega328.
A Quick Review
• In the lab 3, we connect the LED to pin GND and Pin
19, but actually in the program we define the Port
13, why?
Lab2ppt
Reference
• [1] Arduino Internal, Wheat, Dale.
• [2] Slides of Dr. Huang Peisen.
• [3] www.arduino.cc

More Related Content

PPT
Arduino presentation by_warishusain
PDF
Arduino Workshop Day 2 - Advance Arduino & DIY
PPTX
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauri
PPTX
Introduction to Arduino
PDF
Arduino Workshop Day 1 - Basic Arduino
PPTX
Lesson sample introduction to arduino
PPTX
Introduction to Arduino and Hands on to Iot
PPT
Arduino
Arduino presentation by_warishusain
Arduino Workshop Day 2 - Advance Arduino & DIY
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauri
Introduction to Arduino
Arduino Workshop Day 1 - Basic Arduino
Lesson sample introduction to arduino
Introduction to Arduino and Hands on to Iot
Arduino

What's hot (20)

PPTX
Arduino Workshop
PPTX
Introduction to arduino ppt main
PPTX
Introduction to Arduino
PPTX
Different Arduino Boards
PDF
Arduino- Serial communication
PPTX
Arduino
PPTX
Introduction to Arduino
PPTX
Arduino slides
PPTX
Ardui no
PPT
Intro to Arduino
PPTX
Arduino course
PPS
What is Arduino ?
PPTX
Wi-Fi Esp8266 nodemcu
PPTX
Introduction to Arduino Hardware and Programming
PPTX
Aurdino presentation
PPTX
Arduino presentation
PPTX
Basics of arduino uno
ODP
Introduction to Arduino
PPTX
PPT ON Arduino
Arduino Workshop
Introduction to arduino ppt main
Introduction to Arduino
Different Arduino Boards
Arduino- Serial communication
Arduino
Introduction to Arduino
Arduino slides
Ardui no
Intro to Arduino
Arduino course
What is Arduino ?
Wi-Fi Esp8266 nodemcu
Introduction to Arduino Hardware and Programming
Aurdino presentation
Arduino presentation
Basics of arduino uno
Introduction to Arduino
PPT ON Arduino
Ad

Viewers also liked (6)

PDF
How to measure frequency and duty cycle using arduino
DOCX
Voltage measurement using arduino
PPT
Arduino Introduction by coopermaa
DOCX
Project Report
PDF
Gas Leakage Detector using Arduino with SMS Alert - Engineering Project
PDF
Arduino Lecture 1 - Introducing the Arduino
How to measure frequency and duty cycle using arduino
Voltage measurement using arduino
Arduino Introduction by coopermaa
Project Report
Gas Leakage Detector using Arduino with SMS Alert - Engineering Project
Arduino Lecture 1 - Introducing the Arduino
Ad

Similar to Lab2ppt (20)

PPTX
arduino and its introduction deep dive ppt.pptx
PPT
Introduction to Arduino 16822775 (2).ppt
PDF
Starting with Arduino
PPTX
arduino uno.pptx
PPTX
Lecture2- Smart Parking Assistant using Arduino
PPTX
INTODUCTION OF IOT AND INTERFACING WITH ARDUINO UNO
PDF
VERY NICE FOR CSE 3RD YEAR AND IOT STUDENTS
DOCX
embedded manual for students to learn and do
PDF
PPT
IoT Basics with few Embedded System Connections for sensors
DOCX
Arduino embedded systems and advanced robotics
PDF
Arduino microcontroller ins and outs with pin diagram
PDF
Sonar Project Report
PPTX
arduino uno
PPTX
arduinoedit.pptx
PPTX
IOT ARDUINO UNO.pptx
PPT
Physical prototyping lab2-analog_digital
PPT
Physical prototyping lab2-analog_digital
PPTX
Internet of Things prescribed by University
PPTX
Arduino intro.pptx
arduino and its introduction deep dive ppt.pptx
Introduction to Arduino 16822775 (2).ppt
Starting with Arduino
arduino uno.pptx
Lecture2- Smart Parking Assistant using Arduino
INTODUCTION OF IOT AND INTERFACING WITH ARDUINO UNO
VERY NICE FOR CSE 3RD YEAR AND IOT STUDENTS
embedded manual for students to learn and do
IoT Basics with few Embedded System Connections for sensors
Arduino embedded systems and advanced robotics
Arduino microcontroller ins and outs with pin diagram
Sonar Project Report
arduino uno
arduinoedit.pptx
IOT ARDUINO UNO.pptx
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digital
Internet of Things prescribed by University
Arduino intro.pptx

Lab2ppt

  • 2. Today’s schedule • Lecture 1: Arduino • Install Arduino driver • Lab 1: use Arduino UNO to control LED. • Lecture 2: Sensor and Feedback • Lab 2: use Arduino UNO and ultrasonic distance sensor to measure distance • Lecture 3: Minimum system • Lab 3: Building minimum system using AVR chip.
  • 3. What is Arduino? • Official definition: A combination of hardware, software, development team, design philosophy. • From Ivrea, Italy.(意大利的艾维里) • Hardware include Arduino UNO and Arduino Mega, Software include Arduino IDE. • Arduino UNO: Development board of AVR chips. • Arduino UNO is announced in 2011. • UNO Punto Zero (1.0)
  • 4. What can Arduino UNO do? Self-balanced Car
  • 5. What can Arduino UNO do? LED-Cubic
  • 6. Arduino Components Processor USB Ports Power Supply power & Serial Communicate Connection with outside world Supply power Process information & Make decision
  • 8. Install Arduino driver Refer to the PDF file from the announcement on SAKAI. For Windows 7 Operating Systen: • Step 1: Download Arduino IDE and unzip it. • http://arduino.googlecode.com/files/arduino-1.0.5-r2- windows.zip • Step 2: Plug in Arduino UNO board. • Step 3: Right-click This PC  Manage Other device Right-click Unknown deviceUpdate driver Scan the driver folder in Arduino IDE. For Windows 8/8.1, please refer to PDF file. For Mac OS/Linux, Skip this slides.
  • 10. Arduino IDE • An integrated development environment designed for Arduino hardware. • The language is C++ - like. • Process of doing Arduino Project: • Connect hardware with Arduino UNO • Write program on Arduino IDE. • Download it onto Arduino UNO. • Power Arduino UNO on and enjoy it.
  • 11. Arduino IDE • Structure: two necessary functions: 1. void setup(){} 2. void loop(){} • The relationship between Arduino Language and C++ Language. • Important sentence: pinMode (PinNumber,Mode); (general in setup(){};) digitalWrite (PinNumber, DigitalVoltage); delay (MiliSeconds);
  • 12. Lab #1: Light up LED • Requirement: • Light up LED and keep 3 seconds, than power it off and keep 3 seconds. • Repeat the procedure. • DIY
  • 13. Quite easy, right? void setup() { //Connect LED resistor on pin 13. pinMode(13,OUTPUT); } void loop() { digitalWrite(13,HIGH); delay(5000); digitalWrite(13,LOW); delay(5000); }
  • 14. Quick Review • You have controlled the On and Off of LED by control the output voltage of a certain port. • The voltage on pin 13 is called digital signal, which can be either 1 (logical-high voltage) or 0 (logical- low voltage). • Actually, Arduino UNO can output/input digital/analog signals.
  • 15. Sensor(传感器) • Arduino is like a brain. It also needs ears, eyes, nose, etc. to measure quantities in outside environment. • Sensor serves as the connection between Arduino and the outside environment. • So called Feed back control Temp. Sound Light … Environment
  • 16. Velocity Sensor -- Tachometer Velocity sensor – Tachometers Where K is the back EMF constant. Every car has a tachometer so as to measurer to measure speed. (t) K (t)t vwV 
  • 17. Temperature Sensor • Three classes f temperature sensors: • Thermometers and bimetallic strips ---- Sensors which change physical dimension as a function of temperature. • RTDs and thermistors ----Sensors which change resistance as a function of temperature. • RTD: • Thermistor: • Thermocouples ----Sensors which work based on thermoelectric phenomena 0 0(1 (T T ))R R    0 1 1 ( ) 0 T T R R e   
  • 18. Ultrasonic sensor • Ultrasonic sensors are used to measure distance. • An impulse of ultrasonic wave is emitted from the sensor. The wave will reflect when reaches some obstacles. The time between emission and receiving will be calculated. • Use formula to calculate the distance. / 2L Vt
  • 19. HC-SR04 ultrasonic sensor • Four pins (GND, VCC, Trig, Echo) • GND and VCC is the power supply to this module. • Arduino UNO send message to Trig, and read message from Echo.
  • 20. Serial Ports (COM,串口) Communication • Serial is one way in which information is transferred between computer & Arduino. • Information can also be transferred using Parallel Ports.(并口) • Two important sentence of serial communication. • Serial.begin(BaudRate); (must be in setup()) • Serial.write(message);
  • 21. Lab 2: Use ultrasonic sensor to measure distance Electronic components Number Note Arduino UNO 1 With USB wire HC-SR04 Sensor 1 Wires 4 Arduino UNO HC-SR04 Note GND GND VCC VCC A1 (Pin 15) Trig A0(Pin 14) Echo Lab equipment: Wire connection
  • 22. Program void loop() { digitalWrite(TrigPin, LOW); delayMicroseconds(2); digitalWrite(TrigPin, HIGH); delayMicroseconds(5); digitalWrite(TrigPin, LOW); cm = int(pulseIn(EchoPin, HIGH) / 58.0); Serial.println(cm); } const int TrigPin = 15; const int EchoPin = 14; float cm; void setup() { Serial.begin(9600); pinMode(TrigPin, OUTPUT); pinMode(EchoPin, INPUT); }
  • 23. Quick Review • Sensor: connection between Arduino and outside environment. • Serial: one way in which information is transferred.
  • 24. AVR • AVR is a family of MCU chips which are produced by ATMEL Company. • The AVR chip on Arduino UNO is Atmega328. • The AVR chip on Arduino MEGA is Atmega2560 • Working environment: • Stable 5V power supply • Time reference input • (RESET)
  • 25. Atmega328P-PU • Pin number and counting order. • Significant pin for working. • Power supply: PIN7, PIN8, PIN20, PIN22. • RESET: PIN1 • Timing: PIN9, PIN10 • Serial Ports: PIN2, PIN3
  • 26. Min. Sys. Of Atmega328P-PU • Minimum system: MCU chip with simplest peripheral circuit. (外围电路). • Below is the circuit for min. sys. of Atmega328P.
  • 27. Lab 3: Min. Sys. Of Atmega328P • Step 1 Remove the MCU chip on Arduino.
  • 28. Step 2. Build the minimum system
  • 29. Step 3 Connect LED and download program • Connect the series of LED and resistor to pin GND and pin 19. • Connect the Arduino PCB and your computer as is done in Lab 1. • Write exactly the same program as in Lab 1 without any change. • Click the Download button. • See what happen~~^_^
  • 30. Step 3 Connect LED and download program • When the download process has been down, you can remove the RESET line and RX TX line, just leaving the VCC and GND so as to give power to the Atmega328.
  • 31. A Quick Review • In the lab 3, we connect the LED to pin GND and Pin 19, but actually in the program we define the Port 13, why?
  • 33. Reference • [1] Arduino Internal, Wheat, Dale. • [2] Slides of Dr. Huang Peisen. • [3] www.arduino.cc