3 Arduino Introduction m3 Hardware Slides

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Hardware basics

Jon Flanders
@jonflanders
What you will learn

 The basics of using Arduino’s hardware capabilities


The Board (UNO)

 Every board has a few common features


 some slight variations between models
Digital pin
area

USB

Analog pin
area
Power

power pin
area
Powering the board

 USB generally powers the board


 In “production” deployment, you can use a power supply or a battery
 You want to supply between 7 to 12 volts only
 lower voltage and the board might not work properly
 higher voltage and the board might short out
Power pins

pin purpose
provide information about
IOREF
power to shields
power to this pin will reset the
board (typical used by shields
RESET
that block board’s reset IOREF
button) RESET
3.3v provide 3.3v of power output 3.3V
5V
5v provides 5v of power output GND
GND
GND Ground pin
Vin
GND Ground pin

Can power board through this


Vin pin, or get power if powered
by power supply
Digital pins

 Digital pins can be used for


input or output 13
12
 UNO has 14 digital pins
11
 3, 5, 6, 9, 10, and 11 also
10
provide analog signals using
pulse-width modulation 9
(PWM) 8
 0 and 1 can be used for 7
serial communication 6
 10-13 can be used for Serial 5
Peripheral Interface (SPI) 4
communication 3
2
1
0
Digital pin function review

 pinMode - configures one of the digital pin for either input or output
 pinMode(pin,mode)
 Mode is one of three constants
 INPUT - pin accepts input
 OUTPUT - pin output
 INPUT_PULLUP - pin accepts input, but the result is inverted from INPUT
 digitalWrite will change the voltage of a pin set to OUTPUT mode
 digitalRead reads the voltage of a pin set to INPUT or INPUT_PULLUP
 HIGH and LOW constants are used to write or compare read values
 HIGH == 5v
 LOW == 0V
Analog pins

 Analog pins are used for input


A0  Uno has 6
A1  A4 and A5 support I2C (aka TWI )
A2  used by a number of available devices
A3  A4 is the data line (SDA)
A4  A5 is the clock line (SCL)
A5
analogRead/analogWrite

 analogRead is used on the analog input pins


 detects values of 0 to 1024 from devices that output an analog signal
 a call to analogReference can change this resolution
 analogWrite is used on the PWM digital pins
 writes out values from 0 to 255
Using a breadboard
 Solder-less prototyping board
 name is historical when wooden cutting boards where often used
 Breadboard + jump-wires makes it much easier to try out different
ideas
 soldering takes time and is more permanent
Speaker

 Arduino includes a tone function


 pass in duration and frequency
 board generates a square wave of that frequency with a 50% duty cycle
 you need to delay before next tone to “enunciate” between them
 noTone function to stop the wave
 Other ways of sound/music output with Arduino
 MIDI shields
Summary

 Arduino boards have two main sets of functionality: power input and
power output
 Digital power output: 0V and 5V
 Analog power output: 0V to 5V based on scale of 0 to 255
 Analog input based on scale of 0 to 1024
 Breadboards are an almost essential tool for prototyping with Arduino

You might also like