You are on page 1of 41

GETTING STARTED GUIDE

António Moreira
Summary
2

 Arduino presentation
 Shields and Add-ons
 Using the Arduino
 How to program
 IDE

 Arduino Language
 Arduino Library's

 Examples
What is Arduino ?
3

“Arduino is an open-source electronics prototyping


platform based on flexible, easy-to-use hardware
and software. It's intended for artists, designers,
hobbyists, and anyone interested in creating
interactive objects or environments.”
What is Arduino ?
4

 A small, open-source, affordable, easy-to-program


microcontroller (AVR ATmega328)
 32K RAM
 Up to 16Mhz clock
 USB Powered
 Cheap ~20€
 Shields & add-ons
Hardware
5

 External Input Voltage 7-12V


 Analog Input Pins (10bits) – 6
 Digital I/O Pins – 14
6 for PWM output
 In System Programming – ISP
 SPI / I2C
 Serial RX / TX
 Reset Button
Arduino Variants
6

Arduino Nano

LilyPad
Arduino Mini

Arduino Uno Mega


Arduino Fio
Shields & Add-ons
7

 Arduino Shields ?
 Shields are boards that can be plugged on top of the
Arduino PCB extending its capabilities.
 Easy to mount and cheap to produce.

 Examples:
 Bluetooth, Wifi, GPS, Xbee, Ethernet, CANBus
 Lcd, MP3, Sdcard, RFID, 6Dof IMU
 Motor/Servo Control, Extended IO’s
Shield Examples
8
Applications ?
9

 PC data acquisition
 Accelerometer, temperature, light, touch…
 External control, motors, Lcd’s…

 Projects
 Interactive walls
 Robots

 Home Automation
How to start using ?
10

 Hardware required:
1 PC (windows, mac or linux)
 1 Arduino (uno, mega, lilypad)

 1 USB cable

 Software required:
 Install
Arduino IDE
 www.arduino.cc
Arduino IDE
11

Verify: Checks the current program


for errors.
Upload: Transfer the current program
to the microcontroller.

Serial Monitor: Open the serial port and


starts monitoring for communications. “your program here”

The Arduino language is implemented in C/C++

Arduino programs can be divided in three


main parts: structure, values (variables
and constants), and functions.
Arduino IDE
12

Verify: Checks the current program


for errors.

Output: Returns the result of compile


the current program – “delayy” was
not declared…
First define the target Board!
Arduino IDE
13

Upload: Send the compiled code to


Arduino.

Output: Uploading to Arduino, if no


Arduino is detected and error will
appear.
First define the COM port!
Configuring IDE
14

 1º Select current platform


 Tools  Board  Select Platform (Uno/Duemilanove)
 2º Select the correct serial port
 Tools  Serial Port  (COM X)

Upload !
Arduino Language
15

… … …
Arduino Language
16

The setup() function is called when a sketch


starts. Use it to initialize variables, pin modes,
start using libraries, etc. The setup function will
only run once, after each power up or reset of
the Arduino board.

After creating a setup() function, which


initializes and sets the initial values, the loop()
function loops consecutively, allowing your
program to change and respond. Use it to
actively control the Arduino board.
Arduino Library's
17
Arduino Library's
18
Example 1 – Led Blink
19
Example 1 Description
20

 setup()
 function is called when a sketch starts.
 Initialize mode of pin 13.

 The setup function will only run once, at each power up


or reset of the board.

 loop()
 The loop() function performs a continuous loop, allowing
the program to change the output pin value and wait
some time.
Example 1 Description
21

 pinMode(13,OUTPUT)
 Define the pin 13 direction as output

 digitalWrite(13, HIGH) and digitalWrite(13, LOW)


 Set the pin 13 value as High “1” = 5v or Low “0” = 0v

 delay(1000)
 Stop the execution during 1000 milliseconds

 The program blinks the Arduino onboard led !


Example 2 - Analog InOut Serial
22

 Reads the analog input pin 0 (A0)

 Maps the result to a range from 0 to 255


and uses the result to set the pulse width
modulation (PWM) of an output pin.

 ADC 10bits 210 = 1024 ⇒ Vref ?


 analogReference( type )

 Also prints the results to the serial monitor.


(RS232)
Example 2 – Variable led blink
23

Analog input pin - potentiometer


Analog output pin - led

Initialize serial communications at 9600 bps

Read the analog in value


Map to the range of the analog out
Change the analog out value PWM

Print the results to the serial monitor


Example 2
24

ADC

SAR (successive
approximation register)
𝑉𝑟𝑒𝑓
𝑅𝑒𝑠𝑜𝑙𝑢𝑡𝑖𝑜𝑛 =
1024

TX
SERIAL RX

• Text & Data Values


• Interaction
Example 2 – Other sensors
25

• Resistive Sensors • Piezoelectric Sensors

ARDUINO
Filter/
Buffer • Digital Sensors
o RS232
o I2C/SPI
o OneWire
o CANbus
Example 3 - Accelerometer
26

• An accelerometer is an electromechanical
device that will measure acceleration
forces.
• These forces may be static, like the
constant force of gravity pulling at your
feet, or they could be dynamic - caused
by moving or vibrating the accelerometer.
Example 3
27

Read the analog value of 3 axis

Print the results to the


serial monitor
Example 4 – Temperature DS1820
28

 The DS18B20 digital thermometer


provides 9-bit to 12-bit Celsius
temperature measurements.

 Range of -55°C to +125°C and


accurate to ±0.5°C

µC
 1-Wire® bus

 External contributed library


Example 4 – Add library
29

1º Extract “DallasTemperature_360.zip”

3º After copy/move folders restart Arduino !


Example 4 – Add library
30

4º Check if libraries are recognized by Arduino.


Example 4
31
Example 4
32
Example 5 - RangeFinder
33

• 42kHz Ultrasonic sensor

• Operates from 2.5-5.5V

• Low 2mA supply current

• 20Hz reading rate

• Output
• Analog (10mV/inch)
• PWM
• RS232
Example 5
34
Example 6 - LCD
35

• Alphanumeric LCD 16x2


• 4 or 8 bits interface
• Custom characters
Example 6
36
Example 7 – All in one
37
Example 7
38
Example 7
39
Main Advantages
40

 Affordable !
 Easy to use and to program !
 vs AVR C or ASM
 Shields for extended features !
 Many examples, projects and forums !
 Many Libraries !

“Arduino allows to move beyond the cyberspace and


into the real world…”
Useful links
41

 www.arduino.cc
 arduino.cc/forum/
 arduino.cc/playground/
 shieldlist.org/
 www.sparkfun.com/
 www.adafruit.com

 Thanks !

You might also like