Download introduction-to-the

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Brushed DC electric motor wikipedia , lookup

Electrical substation wikipedia , lookup

Current source wikipedia , lookup

Stepper motor wikipedia , lookup

Power engineering wikipedia , lookup

Power inverter wikipedia , lookup

Geophysical MASINT wikipedia , lookup

Rectifier wikipedia , lookup

Pulse-width modulation wikipedia , lookup

Voltage optimisation wikipedia , lookup

Control system wikipedia , lookup

Electrical ballast wikipedia , lookup

Variable-frequency drive wikipedia , lookup

Resistor wikipedia , lookup

Alternating current wikipedia , lookup

Buck converter wikipedia , lookup

Mains electricity wikipedia , lookup

Two-port network wikipedia , lookup

Surface-mount technology wikipedia , lookup

Schmitt trigger wikipedia , lookup

Power electronics wikipedia , lookup

Potentiometer wikipedia , lookup

Switched-mode power supply wikipedia , lookup

Resistive opto-isolator wikipedia , lookup

Immunity-aware programming wikipedia , lookup

Opto-isolator wikipedia , lookup

Transcript
Introduction to Arduino
Microcontrollers
(Death by Powerpoint)
Overview

Background
Microcontroller defined/Why Arduino's?
 Types of Arduino microcontrollers




What To Get (Hardware and Software)
Electronic Circuits
Projects
Examples
 Inspiring the next generation of coders, hardware
experts and tinkers.

Microcontrollers – One
Definition






Programmers work in the virtual world.
Machinery works in the physical world.
How does one connect the virtual world to the
physical world?
Enter the microcontroller.
A microcontroller is basically a small-scale
computer with generalized (and programmable)
inputs and outputs.
The inputs and outputs can be manipulated by
and can manipulate the physical world.
Arduino – Official Definition

Taken from the official web site (arduino.cc):

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.
Why Arduino?

For whatever reason, Arduino microcontrollers
have become the de facto standard.


Make Magazine features many projects using Arduino
microcontrollers.
Strives for the balance between ease of use and
usefulness.
Programming languages seen as major obstacle.
 Arduino C is a greatly simplified version of C++.


Inexpensive from as little as £1!.
Why Arduino in Education?







Programming Skills.
Electronic Skills.
Making the leap.
Inspiration.
Practical learning. Hacking! (Changing the way
things work)
Cost!
So much so that the BBC got in on the act with
>
The BBC Micro:bit







Still a microcontroller.
Similar concept.
Similar abilities.
Similar programing.
Beginner friendly.
Will be everywhere.
Not as practical for bigger projects.
Learn through Doing.
We learn fastest when inspired to play.
 To Tinker.
 To create, debug, and make something that works!
 Electronics are cheap, kids can afford to create, play
with and break / rebuild all sorts of projects.
 Basic Arduino kits are cheap enough to give to kids!
 Electronics are not a form of magic, take control.

What Can Arduino Do?





It can CONTROL devices.
It can SENSE through sensors.
It can INTERACT with the environment.
It can PROCESS what it senses.
It can OUTPUT to other devices or programs.
Practical Applications.








Displays.
Data Logging.
Robots.
Hacking.
Toys.
Games.
Creating.
Controlling.
Arduino Types

Many different versions
Number of input/output channels
 Form factor
 Processor







Leonardo
Due
Micro
LilyPad
Esplora
Uno
Arduino Uno Close Up

The pins are in three groups:
Invented in 2010
 14 digital pins
 6 analog pins
 power

Micro



When size matters: Micro, Nano, Mini
Includes all functionality of the Leonardo
Easily usable on a breadboard
LilyPad

LilyPad is popular for clothing-based projects.
Where to Start








Get an Arduino (starter kit).
Download the the IDE.
Connect the Arduino.
Configure the compiler.
Connect the circuit.
Write the program.
Get frustrated/Debug/Get it to work.
Get excited and immediately start next project
(sleep is for wimps)
Arduino Starter Kits

Pre Selected Retail Kits.


Ebay Kits.


Advantage that multiple projects (and instructions)
are usually included.
Usually of very good quality and much cheaper than
retail.
Website Lists and purchase through Ebay.

There are a plethora of sites offering part lists for
the beginner with associated projects.
Typical £20 Kit.
Shields



Shields are circuit boards that plug into the top
of an Arduino.
They extend the capabilities of an Arduino.
Examples:
Ethernet
 GPS
 Motor
 Prototype


shieldlist.org
What to Get – My Recommendation

Required:








Arduino (such as Uno)
USB A-B (printer) cable
Breadboard
Hookup wire
LED's
Resistors
Sensors
Switches

Good Idea:





Capacitors
Transistors
DC motor/servo
Relay
Advanced:




Soldering iron & solder
Heat shrink tubing
9V battery adapter
Bench power supply
What to get (Advanced)
LCD Shield.
 Multi Input Output Board.
 Motor Control Shield.
 Servos.
 Relays.
 Led Strips.
 Prototype boards & Shields.
 Bread Boards with PSU.
 Lots of leds, resistors, motors, transistors & wires!

Arduino Program Development




Based on C++ without 80% of the instructions.
A handful of new commands.
Programs are called 'sketches'.
Sketches need two functions:
void setup( )
 void loop( )



setup( ) runs first and once.
loop( ) runs over and over, until power is lost or
a new sketch is loaded.
Arduino C


Arduino sketches are centered around the pins
on an Arduino board.
Arduino sketches always loop.


void loop( ) {} is equivalent to while(1) { }
The pins can be thought of as global variables.
Arduino C Specific Functions

pinMode(pin, mode)
Designates the specified pin for input or output

digitalWrite(pin, value)
Sends a voltage level to the designated pin

digitalRead(pin)
Reads the current voltage level from the designated pin

analog versions of above


analogRead's range is 0 to 1023
serial commands

print, println, write
Compiler Features



Numerous sample
sketches are included in
the compiler
Located under File,
Examples
Once a sketch is written,
it is uploaded by clicking
on File, Upload, or by
pressing <Ctrl> U
Basic LED Circuit


Connect the positive (+) lead of a power
source to the long leg of an LED.
Connect other leg of the LED to a resistor.
High resistance means a darker light.
 Low resistance means brighter light.
 No resistance means a burned out LED.


Connect other leg of the resistor to the
negative lead of the power source.
Let the Good Times Roll!

At this point we have:
Purchased a starter kit, including the Arduino
 Connected and configured the Arduino
 Connected a simple LED circuit


Let's write some code!
Blink Sketch
void setup( ) {
Connected to one end
pinMode(13, OUTPUT); of the circuit
}
void loop( ) {
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
Connected to other end
of the circuit
So What?




Great. Blinking lights. Not impressed.
Blinking Signal can be reused in hundreds of
projects. Control sirens, flashing lights, motors,
valves, an SOS Beacon Project (light and sound).
Only covered output thus far.
Can use analog inputs to detect physical
phenomena.
Inputs

Digital inputs will come to the Arduino as either
on or off (HIGH or LOW, respectively).
HIGH is 5VDC.
 LOW is 0VDC.


Analog inputs will come to the Arduino as a
range of numbers, based upon the electrical
characteristics of the circuit.
0 to 1023
 .0049 V per digit (4.9 mV)
 Read time is 100 microseconds (10,000 a second)

Analog Input-Application


The variable resistor can be replaced with a
sensor.
For example, a photo resistor.

Depending upon the light level at the photo resistor:
Turn on a light
 Increase or decrease the brightness of an LED (or an
LED array)


Most sensors are simply variable resistors, but
vary their resistance based on some physical
characteristic.
Sensors




Sensors can be both binary or a range.
Usually, sensors that measure a range of values
vary their resistance to reflect their detection.
Arduinos can only sense voltages, not
resistances.
Sensors that only vary their resistances require a
circuit called a voltage divider to provide the
Arduino a voltage.
Common Sensors





Dials on a radio are
simply potentiometers
Temperature
Light
Angle
Switches


did the user throw a
switch or push a button?
Accelerometer (measures
motion and tilt)




Infrared sensor & light
Hall effect sensor and
magnet
Ball tilt sensor (for
measuring orientation)
Force
Projects.








Hacking pound shop electronics.
Anoyatron.
Data Loggers for science projects.
Distance Sensor.
Pretty Lights.
Automation.
Solve a real world problem.
Clock.
Anoyatron.






Costs < £2
Beeps at random intervals.
Takes less that 30minutes to make.
Runs on a single 3v Battery.
Will run for 40 years on the power from this
single battery.
Wins friends in the workplace!
Advanced Projects.








Robots!
Big Displays!
3D Scanners & Printers!
Drones!
Intruder Alarm.
CNC Machine.
LED interactive table.
Web Server.
Simple Robot.

Features,
Self correcting.
 Handles Multiple tasks.
 Various Logic for dealing with obstacles.
 Behaviour seems more intelligent than it is.
 Works by repeatedly banging it’s head on walls.
 Seems well suited to an educational environment.

Conclusion


The Arduino microcontroller is a low cost way
to enter into the hobby of robotics &
Electronics.
The Arduino has two plusses over any other:
The user community
 Extensive online library of code and projects



Viewed as the "base" system, upon which all
other microcontrollers are built. Compatibility.
So get a kit, and start ushering in the inevitable
takeover of our robotic overlords!
Introduction to Arduino
Microcontrollers