ukrainianlegalΗλεκτρονική - Συσκευές

2 Νοε 2013 (πριν από 4 χρόνια και 8 μήνες)

194 εμφανίσεις




Introduction to Arduino UNO and Danger Shield

Department of Electrical and Computer Engineering

University of Nevada, Las Vegas


This section introduces the basic hardware involved in

the experiments and activities performed in
these laboratory exercises. Namely the Arduino UNO and Danger Shield.


Familiarize the user with the Arduino UNO

Familiarize the user with the Danger Shield

Overview and

Arduino De
velopment Platform

“Arduino is an open
source electronics prototyping platform based on flexible, easy
hardware and software. It's intended for artists, designers, hobbyists, and anyone
interested in creating interactive objects or environments.”


At its core, the Arduino development platform is
a microcontroller placed in a development shell
with all the necessary components to make it
easy to use. Arduino’s flagship platform is the
Arduino Uno, a microcontroller board bas
ed on
the Atmega328.
It ha
s 14 digital input/output
, 6 analog inputs, a 16 MHz crystal oscillator,
a USB connection, a power jack, an ICSP header,
and a reset button.
It is all encompassing in
terms of supporting and using the
microcontroller. It ca
n be powered via an AC adapter or connected to a computer via USB,
which is also used for programming.


Microcontrollers are small integrated circuits that are
used in a wide variety of day to day household
products and applications. They consist of a
processor, memory, and programmable
inputs/output peripherals to control. You can think
of it as a small c
omputer on a single integrated
circuit, typically designed for embedded applications.
Microcontrollers are designed to execute specific tasks to control a system, such as
taking input from a remote control to change the channel on a television.

ntrollers have become quite common in many products such as appliances,
computer equipment, automobiles, and extending as far as industrial robotics. They
are designed to be self sufficient and cost effective, giving them a use in a large
variety of speci
fic tasks. If you can think of any digital interface used in many
household appliances or technological devices you can very safely assume that a
microcontroller is involved in the control of the interface.


The Arduino Uno can be powered via the

USB connection or with an external power
supply. The power source is selected automatically.

External (non
USB) power can come either from an AC
DC adapter (wall
wart) or
battery. The adapter can be connected by plugging a 2.1mm center
positive plug
into the board's power jack. Leads from a battery can be inserted in the Gnd and Vin
pin headers of the POWER connector.

The board can operate on an external supply of 6 to 20 volts. If supplied with less
than 7V, however, the 5V pin may supply less than

five volts and the board may be
unstable. If using more than 12V, the voltage regulator may overheat and damage
the board. The recommended range is 7 to 12 volts.

The power pins are as follows:

VIN: The input voltage to the Arduino board when it's usi
ng an external power
source (as opposed to 5 volts from the USB connection or other regulated power
source). You can supply voltage through this pin, or, if supplying voltage via the
power jack, access it through this pin.

5V: This pin outputs a regulate
d 5V from the regulator on the board. The board can
be supplied with power either from the DC power jack (7

12V), the USB connector
(5V), or the VIN pin of the board (7
12V). Supplying voltage via the 5V or 3.3V pins
bypasses the regulator, and can damag
e your board. We don't advise it.

3V3: A 3.3 volt supply generated by the on
board regulator. Maximum current draw
is 50 mA (milliAmps).

GND: Ground pins.


The ATmega328 has 32 KB (with 0.5 KB used for the bootloader). It also has 2 KB of
SRAM and 1 KB of EEPROM (which can be read and written with the EEPROM

Input and Output

Each of the 14 digital pins on the Uno can be used as an input or output
. They
operate at 5 volts. Each pin can provide or receive a maximum of 40 mA and has an
internal pull
up resistor (disconnected by default) of 20
50 kOhms.

Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data. These
pins are
connected to the corresponding pins of the ATmega8U2 USB
TTL Serial

External Interrupts: 2 and 3. These pins can be configured to trigger an interrupt on
a low value, a rising or falling edge, or a change in value. See the attachInterrupt()
tion for details.

PWM: 3, 5, 6, 9, 10, and 11. Provide 8
bit PWM output with the analogWrite()

SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication
using the SPI library.

LED: 13. There is a built
in LED connec
ted to digital pin 13. When the pin is HIGH
value, the LED is on, when the pin is LOW, it's off.

The Uno has 6 analog inputs, labeled A0 through A5, each of which provide 10 bits
of resolution (i.e. 1024 different values). By default they measure from gr
ound to 5
volts, though is it possible to change the upper end of their range using the AREF pin
and the analogReference() function. Additionally, some pins have specialized

TWI: A4 or SDA pin and A5 or SCL pin. Support TWI communication u
sing the Wire

AREF. Reference voltage for the analog inputs. Used with analogReference().

Reset. Bring this line LOW to reset the microcontroller. Typically used to add a reset
button to shields which block the one on the board.


Danger Shield

The Danger Shield is a top mounted Arduino UNO shield
that equips a large variety of inputs and outputs to the
Arduino without the use of any kind of breadboard. Each
input/output is connected to the Arduino’s digi
tal and
analog pins.

Analog pins 0 to 2 connects to 3 individual 10k ohm
linear slide potentiometers output an analog value
between 0 and 1024.

Analog pin 3 is connected to a photocell. This
device chances resistance depending on the
amount of light it

is exposed to.

Analog pin 4 is connected to a temperature sensor which sends out an analog value
representative of the current ambient temperature.

Digital pins 2 and 9 are connected to a capacitve touchpad, which is able to sense
touch when pressure is a
pplied to the area.

Digital pin 3 is connected to a small 12mm round buzzer that operates in the 2kHz
range. It can be used to generate various sounds and even create simple music.

Digital pins 5 and 6 are connected to LED’s in series with a 330 ohm resis
tor. For
these labs the LED’s will be red and green respectively.

Digital pins 4, 7, and 8 are connected to the 8
bit shift register, which is used to drive
the 7 segment display.

Digital pins 10 to 12 are connected to momentary push buttons that send the

low when buttons are pressed (low active).

The following exercises will display the use and function of the potentiometers and the capactive


Arduino Uno

B Cable

Danger Shield

Host PC

Installed Arduino Uno drivers and

Provided Capacative Sensor Library.


Slider Potentiometers


Attach the Danger Shield to the Arduino, making sure to properly align the pins. If you are
using an R3 revision of the Arduino UNO, there will be 2 pins on each side that
will have no
corresponding pins on the shield.


Attach the Arduino UNO to the host PC with the use of the USB cable. Verify that the
drivers have been properly installed.


Open the Arduino IDE and create a new sketch titled “Sliders”. Verify that the
correct COM
port is in use.


Using the previous lab as a guide, verify and upload the following sketch to your Arduino

// Global variables

int val = 0;

// Pin definitions

#define SLIDER1 0

#define SLIDER2 1

#define SLIDER3 2

void setup()


ial.begin(9600); //Start Serial Communication

Serial.println("Danger Shield Potentiometer Test");


void loop()


Serial.print("Sliders: ");

val = analogRead(SLIDER1);

Serial.print(" ");


val = analogRead(SLIDER2);

l.print(" ");


val = analogRead(SLIDER3);

Serial.print(" ");





Verify your results by sliding all 3 potentiometers. The value range should be between 0
and 1023.

Capacitive Sensor


and extract the file included in this lab.


Copy the extracted CapSense folder into the arduino “libraries folder”


Attach the Danger Shield to the Arduino, making sure to properly align the pins. If you are
using an R3 revision of the Ard
uino UNO, there will be 2 pins on each side that will have no
corresponding pins on the shield.


Attach the Arduino UNO to the host PC with the use of the USB cable. Verify that the
drivers have been properly installed.


Open the Arduino IDE and create a
new sketch titled “CapSense”. Verify that the correct
COM port is in use.


Using the previous lab as a guide, verity and upload the following sketch to your Arduino

#include <CapSense.h> //Include the Cap Sense Library into our program

// Global

int val = 0;

CapSense cs_9_2 = CapSense(9,2); //Initializes CapSense pins

void setup()


Serial.begin(9600); //Start Serial Communication

cs_9_2.set_CS_AutocaL_Millis(0xFFFFFFFF); // Calibrates CapSense pin timing

er Shield Cap Sense Test");


void loop()


long start = millis();

long total1 = cs_9_2.capSense(30);





Verify your results by pressing your thumb against the capactive sensor. The value reading
should incr
ease based on the pressure placed on the surface.

Demo and screenshots:

Test Your Understanding:


What optimal voltage range that should be supplied to the Arduino board?


How many digital pins does the Arduino have? What voltage and current do they


How many analog pins are there? Define the SDA and SCL pins.