This was my presentation for the Intro to Arduino class held at Deezmaker 3D Printer Store/Hackerspace 4/6/13. I, Quin/Qtechknow, taught this class along with my ArduSensor Fun Pack, which is available on my website, www.qtechknow.com. We went over some key concepts of Arduino, open source, and circuits. Enjoy!!!
1. Intro to Arduino Class
Deezmaker 3D Printer Store and Hackerspace
Taught by Quin
4/6/13
Saturday, April 6, 13
2. Thank you to SparkFun for
sharing the original
presentation!
Saturday, April 6, 13
3. What is Open Source???
Open source is when you release your
design files (a.k.a. the PCB files,
schematic) to the public, so that
anyone that wants to learn more about
the PCB, can learn for free. When you
release files for a new project you have
made, but you remade/remixed the
files that someone else made, you
have to credit them.
Saturday, April 6, 13
4. Schedule
• Getting started with Arduino and electronics
• Project 1 & 2
• Break
• Project 3 & 4
• Explaining More Code
• Project 5 & 6
• Q&A + Free Project Time
Saturday, April 6, 13
5. Arduino Board
“Strong Friend” Created in Ivrea, Italy
in 2005 by Massimo Banzi & David Cuartielles
Open Source Hardware
Atmel Processor
Coding is accessible/easy (C++, Processing)
Saturday, April 6, 13
6. Why do I want an Arduino?
Arduino is a 8-bit prototyping system
that is easy for the modern developer,
designer, hacker, kid, or someone that
has no experience in this type of genre
to use.
But why is important to all of us?
Saturday, April 6, 13
11. Components
Name Image
Type
Function Notes
Digital Input Closes or Polarized,
Button opens circuit needs resistor
Analog Input Variable
Trimpot resistor
LDR Analog Input Variable Also known as
resistor photoresistor
Temp Analog Input Variable
resistor
Sensor
Flex Sensor Analog Input Variable
resistor
Dig. &
16,777,216 Ooh... So
RGB LED Analog
Output
different pretty.
colors
Saturday, April 6, 13
12. Polarity
Polarity is when there are two or more
different sides (or leads) of a
component that have different
qualities that can not be reversed.
Examples: batteries, LEDs, buttons
Saturday, April 6, 13
13. Power (+5V) and Ground
(GND)
Power is the current that goes through the
circuit, and ground is the current return path
(collector).
Always make sure that Power and Ground never
touch directly, or the circuit will short, and
become very hot.
Make sure to not use over 10V, just 5V, and
3.3V, so no shock will occur.
Saturday, April 6, 13
14. What’s a Breadboard?
One of the most useful tools in an engineer or
Maker’s toolkit. The four most important things
to remember:
• Breadboards are very easy to prototype with
• A breadboard is easier than soldering
• A lot of those little holes are connected, which
ones?
• Breadboards can break, if you
force them too much.
Saturday, April 6, 13
16. Analog and Digital
• All Arduino signals are either Analog or
Digital
• All computers including Arduino, only
understand Digital
• We need a way to convert the analog
signals into digital signals, so that our
Arduino can process them.
Saturday, April 6, 13
17. Analog to Digital Conversion
An ADC is a device that samples a
continuous quantity of analog signals
(sensor signals), compares it to the
time, then outputs a digital signal to
the Arduino. It then turns the digital
signals into 1024 different values.
The ADC (analog) compatible pins on
the Arduino are A0, A1, A2, A3, A4,
and A5.
Saturday, April 6, 13
18. I/O, or Input/Output
Input is any signal
entering an electrical
system/Arduino.
Output is any signal
exiting an electrical
system.
Saturday, April 6, 13
19. Output
Output is always Digital
To Output a Digital signal (On or Off) use this
code:
digitalWrite (pinNumber, value);
Where value is HIGH (on) or LOW (off), both in
caps
Saturday, April 6, 13
20. Output
To output a signal that pretends to be analog
(anywhere in between on and off), you will have
to use a PWM pin.
Use this code to output an ‘analog’ signal:
analogWrite (pinNumber, value);
Where value is a number 0 - 255.
PWM is available on Arduino Leonardo digital pins
3, 5, 6, 9, 10, 11, and 13, and marked with a ‘~’.
Saturday, April 6, 13
21. Output
Using a Digital signal that pretends to be an
Analog signal is called Pulse Width Modulation
Use Pulse Width Modulation, or PWM, for anything
that requires a signal between HIGH and LOW
(1-254, with 0 being off and 255 being on)
PWM turns the output on to off very fast, so fast
that we can’t see it. By changing the 0 - 255 #, we
can change the width of these signals.
Saturday, April 6, 13
22. Output
Output is always Digital, even when it’s P.W.M.
For P.W.M. the Arduino pin turns on, then off very fast
P.W.M. Signal @ 25%
P.W.M. Signal @ 75%
P.W.M. Signal
rising
Saturday, April 6, 13
23. Arduino IDE
The Arduino IDE (Integrated
Development Environment) is where
we develop our code, and deploy/
upload the code to the Arduino
Leonardo Board. You can download
the latest software here:
Arduino 1.0.4:
http://arduino.cc/en/main/software
Saturday, April 6, 13
24. Installing Drivers for Mac
The first time you plug a Leonardo into a Mac, the
"Keyboard Setup Assistant" will launch. There's
nothing to configure with the Leonardo, so you can
close this dialogue by clicking the red button in the
top left of the window.
Saturday, April 6, 13
25. Installing Drivers for Windows
This method has been tested on Windows XP and 7:
• Plug in your board and wait for Windows to begin
its driver installation process. If the installer does
not launch automatically, Navigate to the
Windows Device Manager (Start>Control
Panel>Hardware) and find the Arduino Leonardo
listing. Right click and choose Update driver.
• If prompted to search for drivers online, choose
"No, not this time". And click Next
Saturday, April 6, 13
27. Installing Drivers for Windows
• When asked to install automatically or from a
specific location, select "Install from a list or
specific location" and press Next
Saturday, April 6, 13
28. Installing Drivers for Windows
• Choose "Search for the best driver in these
locations", and check the box "incude this
location in the search". Click the Browse button
and navigate to your Arduino 1.0.1 or later
installation. Select the drivers folder an click OK
Saturday, April 6, 13
30. Installing Drivers for Windows
Click Next. You will receive a notification that the
Leonardo has not passed Windows Logo testing.
Click on the button Continue Anyway
Saturday, April 6, 13
31. Installing Drivers for Windows
• After a few moments, a window will tell you the
wizard has finished installing software for
Arduino Leonardo. Press the Finish button
(from arduino.cc)
Saturday, April 6, 13
43. Why do I make a comment?
• Comments are great ways to
remind you what you did,
teach other people what that
code means, or to make a
long description for your
whole piece of code for
licenses, date, and author
Saturday, April 6, 13
44. Comments
• Comments are ignored by
the compiler/verifier
• Comments can be anywhere
• Comments can start with
a // for a one-line comment
• Another type of comment is
multiple lines and starts with
a /* and ends with a */
Saturday, April 6, 13
46. Input
Input is any signal entering an electrical system
•Both digital and analog sensors are forms of input
•Input can also take many other forms: Keyboards,
a mouse, buttons, light sensors, or just plain
voltage from a circuit
Saturday, April 6, 13
47. Analog Input
• To connect an analog Input to your Arduino, use
Analog/ADC Pins # 0 - 5
• To get an analog reading, use the code:
analogRead(pinNumber);
• Analog Input varies from 0 to 1023 on an
Arduino
Saturday, April 6, 13
48. Downloading Code
https://github.com/Qtechknow/
Arduino-Code/zipball/master/
Saturday, April 6, 13
52. Digital Sensors/Digital Input
• Digital Input could be a switch or a button
• To connect digital input to your Arduino use Digital Pins #
0 – 13 (Although pins # 0 & 1 are also used for serial)
• Digital Input needs a pinMode command (in setup):
pinMode(pinNumber, INPUT);
Make sure to use caps for INPUT
• To get a digital reading: digitalRead(pinNumber);
• Digital Input values are only HIGH (On) or LOW (Off)
Saturday, April 6, 13
53. Digital Sensors/Digital Input
• Digital sensors are more straight forward than
Analog
• No matter what the sensor, there are only two
settings: On and Off (for buttons, pressed or
not)
• Signal is always either HIGH (On) or LOW (Off)
• Voltage signal for HIGH will be a little less than
5V on your Arduino Leonardo
• Voltage signal for LOW will be 0V, and HIGH will
be 5V
Saturday, April 6, 13
54. Parts for Circuit 3:
Arduino Leonardo
Breadboard
Pushbutton (2)
LED (2)
Resistor - 10K Ohm (2)
Resistor - 330 Ohm (2)
Jumper Wires
Saturday, April 6, 13
70. Common Functions
pinMode(pin, kind); (declares pins)
analogRead(pin); (reads an analog pin)
digitalWrite(pin, state); (tells a pin to
turn on (5V), or turn off (0V)
if() {} (tells something to do a function,
when something else happens
for() {} (tells something to do a function
over and over)
Saturday, April 6, 13
71. Setup
void setup ( ) {
Inputs & Outputs are declared in
setup, this is done by using the
pinMode function
This particular example declares digital pin # 13
as an output, remember to use CAPS
Saturday, April 6, 13
72. If Statements
if ( this is true ) { do this; }
Saturday, April 6, 13
73. If
if ( this is true ) { do this; }
Saturday, April 6, 13
74. Conditional
if ( this is true ) { do this; }
Saturday, April 6, 13
75. Action
if ( this is true ) { do this; }
Saturday, April 6, 13