+ All Categories
Home > Technology > Intro to Arduino at Deezmaker by Qtechknow

Intro to Arduino at Deezmaker by Qtechknow

Date post: 19-May-2015
Category:
Upload: qtechknow
View: 407 times
Download: 2 times
Share this document with a friend
Description:
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!!!
Popular Tags:
89
Intro to Arduino Class Deezmaker 3D Printer Store and Hackerspace Taught by Quin 4/6/13 Saturday, April 6, 13
Transcript
Page 1: Intro to Arduino at Deezmaker by Qtechknow

Intro to Arduino Class

Deezmaker 3D Printer Store and Hackerspace

Taught by Quin

4/6/13

Saturday, April 6, 13

Page 2: Intro to Arduino at Deezmaker by Qtechknow

Thank you to SparkFun for sharing the original

presentation!

Saturday, April 6, 13

Page 3: Intro to Arduino at Deezmaker by Qtechknow

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

Page 4: Intro to Arduino at Deezmaker by Qtechknow

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

Page 5: Intro to Arduino at Deezmaker by Qtechknow

Arduino Board“Strong Friend” Created in Ivrea, Italy

in 2005 by Massimo Banzi & David CuartiellesOpen Source Hardware

Atmel ProcessorCoding is accessible/easy (C++, Processing)

Saturday, April 6, 13

Page 6: Intro to Arduino at Deezmaker by Qtechknow

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

Page 7: Intro to Arduino at Deezmaker by Qtechknow

Saturday, April 6, 13

Page 8: Intro to Arduino at Deezmaker by Qtechknow

Arduino Shields PCB Built Shield Inserted Shield

Saturday, April 6, 13

Page 9: Intro to Arduino at Deezmaker by Qtechknow

Arduino Shields

Micro SD MP3 Trigger Joystick

Saturday, April 6, 13

Page 10: Intro to Arduino at Deezmaker by Qtechknow

ArduSensors - ‘Mini Shields’

Saturday, April 6, 13

Page 11: Intro to Arduino at Deezmaker by Qtechknow

ComponentsName Image Type Function Notes

Button Digital Input Closes or opens circuit

Polarized, needs resistor

Trimpot Analog Input Variable resistor

LDR Analog Input Variable resistor

Also known as photoresistor

Temp Sensor

Analog Input Variable resistor

Flex Sensor Analog Input Variable resistor

RGB LED Ooh... So pretty.

Dig. & Analog Output

16,777,216 different colors

Saturday, April 6, 13

Page 12: Intro to Arduino at Deezmaker by Qtechknow

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

Page 13: Intro to Arduino at Deezmaker by Qtechknow

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

Page 14: Intro to Arduino at Deezmaker by Qtechknow

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

Page 15: Intro to Arduino at Deezmaker by Qtechknow

What’s a Breadboard?

Saturday, April 6, 13

Page 16: Intro to Arduino at Deezmaker by Qtechknow

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

Page 17: Intro to Arduino at Deezmaker by Qtechknow

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

Page 18: Intro to Arduino at Deezmaker by Qtechknow

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

Page 19: Intro to Arduino at Deezmaker by Qtechknow

OutputOutput 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

Page 20: Intro to Arduino at Deezmaker by Qtechknow

Output

To output a signal that pretends to be analog(anywhere in between on and off), you will haveto 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

Page 21: Intro to Arduino at Deezmaker by Qtechknow

OutputUsing 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

Page 22: Intro to Arduino at Deezmaker by Qtechknow

OutputOutput 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

Page 23: Intro to Arduino at Deezmaker by Qtechknow

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

Page 24: Intro to Arduino at Deezmaker by Qtechknow

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

Page 25: Intro to Arduino at Deezmaker by Qtechknow

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

Page 26: Intro to Arduino at Deezmaker by Qtechknow

Installing Drivers for Windows

Saturday, April 6, 13

Page 27: Intro to Arduino at Deezmaker by Qtechknow

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

Page 28: Intro to Arduino at Deezmaker by Qtechknow

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

Page 29: Intro to Arduino at Deezmaker by Qtechknow

Installing Drivers for Windows

Saturday, April 6, 13

Page 30: Intro to Arduino at Deezmaker by Qtechknow

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

Page 31: Intro to Arduino at Deezmaker by Qtechknow

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

Page 32: Intro to Arduino at Deezmaker by Qtechknow

Saturday, April 6, 13

Page 33: Intro to Arduino at Deezmaker by Qtechknow

Saturday, April 6, 13

Page 34: Intro to Arduino at Deezmaker by Qtechknow

Board Type

Saturday, April 6, 13

Page 35: Intro to Arduino at Deezmaker by Qtechknow

Serial Port / COM Port

Saturday, April 6, 13

Page 36: Intro to Arduino at Deezmaker by Qtechknow

Which COM/Serial Port?Mac: /dev/tty.usbmodemfd131

Interchangeable #:

Windows: COM#Device Manager:

Start>ControlPanel>System &Security>Device Manager>Ports

Saturday, April 6, 13

Page 37: Intro to Arduino at Deezmaker by Qtechknow

Circuit 1: Basic Blink

Saturday, April 6, 13

Page 38: Intro to Arduino at Deezmaker by Qtechknow

How to get the sketch:

Go to File>Examples>01.Basics>Blink

Saturday, April 6, 13

Page 39: Intro to Arduino at Deezmaker by Qtechknow

39Saturday, April 6, 13

Page 40: Intro to Arduino at Deezmaker by Qtechknow

Parts of the Sketch

Saturday, April 6, 13

Page 41: Intro to Arduino at Deezmaker by Qtechknow

void setup() {}

41Saturday, April 6, 13

Page 42: Intro to Arduino at Deezmaker by Qtechknow

void loop ( ) { }

Saturday, April 6, 13

Page 43: Intro to Arduino at Deezmaker by Qtechknow

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

Page 44: Intro to Arduino at Deezmaker by Qtechknow

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

Page 45: Intro to Arduino at Deezmaker by Qtechknow

Example of Comment:

Saturday, April 6, 13

Page 46: Intro to Arduino at Deezmaker by Qtechknow

InputInput 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

Page 47: Intro to Arduino at Deezmaker by Qtechknow

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

Page 49: Intro to Arduino at Deezmaker by Qtechknow

Circuit 2: Analog Reading

Saturday, April 6, 13

Page 50: Intro to Arduino at Deezmaker by Qtechknow

Saturday, April 6, 13

Page 51: Intro to Arduino at Deezmaker by Qtechknow

Break

Saturday, April 6, 13

Page 52: Intro to Arduino at Deezmaker by Qtechknow

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

Page 53: Intro to Arduino at Deezmaker by Qtechknow

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

Page 54: Intro to Arduino at Deezmaker by Qtechknow

Parts for Circuit 3:

Arduino LeonardoBreadboardPushbutton (2)LED (2)Resistor - 10K Ohm (2)Resistor - 330 Ohm (2)Jumper Wires

Saturday, April 6, 13

Page 55: Intro to Arduino at Deezmaker by Qtechknow

Circuit 3: Buttons

Saturday, April 6, 13

Page 56: Intro to Arduino at Deezmaker by Qtechknow

`

Saturday, April 6, 13

Page 57: Intro to Arduino at Deezmaker by Qtechknow

Saturday, April 6, 13

Page 58: Intro to Arduino at Deezmaker by Qtechknow

Semicolons

Semicolons are needed after every line of code, except for void setup(), void loop(), and a few others

Saturday, April 6, 13

Page 59: Intro to Arduino at Deezmaker by Qtechknow

Operators

The equals sign

= is used to assign a value

== is used to compare values

Saturday, April 6, 13

Page 60: Intro to Arduino at Deezmaker by Qtechknow

Operators

&& is “and”

|| is “or”

Saturday, April 6, 13

Page 61: Intro to Arduino at Deezmaker by Qtechknow

Variables

Basic variable types:

Boolean (on or off)Integer (a number)Character (a letter)

String (a phrase/many letters)

Saturday, April 6, 13

Page 62: Intro to Arduino at Deezmaker by Qtechknow

Declaring Variables

Boolean: boolean variableName;

Integer: int variableName;

Character: char variableName;String: stringName [ ];

Saturday, April 6, 13

Page 63: Intro to Arduino at Deezmaker by Qtechknow

Assigning Variables

Boolean: variableName = true;or variableName = false;

Saturday, April 6, 13

Page 64: Intro to Arduino at Deezmaker by Qtechknow

Assigning Variables

Boolean: variableName = true;or variableName = false;Integer: variableName =

32767;or variableName = -32768;

Saturday, April 6, 13

Page 65: Intro to Arduino at Deezmaker by Qtechknow

Assigning Variables

Boolean: variableName = true;or variableName = false;Integer: variableName =

32767;or variableName = -32768;

Character: variableName = ‘A’;or stringName =

“Deezmaker”;Saturday, April 6, 13

Page 66: Intro to Arduino at Deezmaker by Qtechknow

Variable ScopeWhere you declare your variables

matters

Saturday, April 6, 13

Page 67: Intro to Arduino at Deezmaker by Qtechknow

Circuit 4: ArduSensor + LED

Saturday, April 6, 13

Page 68: Intro to Arduino at Deezmaker by Qtechknow

Circuit 4: ArduSensor+LED

Saturday, April 6, 13

Page 69: Intro to Arduino at Deezmaker by Qtechknow

Saturday, April 6, 13

Page 70: Intro to Arduino at Deezmaker by Qtechknow

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 happensfor() {} (tells something to do a function

over and over)

Saturday, April 6, 13

Page 71: Intro to Arduino at Deezmaker by Qtechknow

Setupvoid setup ( ) {

Inputs & Outputs are declared in setup, this is done by using the

pinMode functionThis particular example declares digital pin # 13

as an output, remember to use CAPS

Saturday, April 6, 13

Page 72: Intro to Arduino at Deezmaker by Qtechknow

If Statementsif ( this is true ) { do this; }

Saturday, April 6, 13

Page 73: Intro to Arduino at Deezmaker by Qtechknow

Ifif ( this is true ) { do this; }

Saturday, April 6, 13

Page 74: Intro to Arduino at Deezmaker by Qtechknow

Conditionalif ( this is true ) { do this; }

Saturday, April 6, 13

Page 75: Intro to Arduino at Deezmaker by Qtechknow

Actionif ( this is true ) { do this; }

Saturday, April 6, 13

Page 76: Intro to Arduino at Deezmaker by Qtechknow

Elseelse { do this; }

Saturday, April 6, 13

Page 77: Intro to Arduino at Deezmaker by Qtechknow

Basic Repetition

for (int count = 0; count<10; count++) {//for action code goes here //this could be anything}

Saturday, April 6, 13

Page 78: Intro to Arduino at Deezmaker by Qtechknow

Basic Repetition

for (int count = 0; count<10; count++) {//for action code goes here }

Saturday, April 6, 13

Page 79: Intro to Arduino at Deezmaker by Qtechknow

Basic Repetition

for (int count = 0; count<10; count++) {//for action code goes here }

Saturday, April 6, 13

Page 80: Intro to Arduino at Deezmaker by Qtechknow

Basic Repetition

for (int count = 0; count<10; count++) {//for action code goes here }

Saturday, April 6, 13

Page 81: Intro to Arduino at Deezmaker by Qtechknow

Basic Repetition

for (int count = 0; count<10; count++) {//for action code goes here }

Saturday, April 6, 13

Page 82: Intro to Arduino at Deezmaker by Qtechknow

Basic Repetition

for (int count = 0; count<10; count++) {//for action code goes here }

Saturday, April 6, 13

Page 83: Intro to Arduino at Deezmaker by Qtechknow

Circuit 5: LED Bounce

Saturday, April 6, 13

Page 84: Intro to Arduino at Deezmaker by Qtechknow

Saturday, April 6, 13

Page 85: Intro to Arduino at Deezmaker by Qtechknow

Saturday, April 6, 13

Page 86: Intro to Arduino at Deezmaker by Qtechknow

Circuit 6: Meter

Saturday, April 6, 13

Page 87: Intro to Arduino at Deezmaker by Qtechknow

Saturday, April 6, 13

Page 88: Intro to Arduino at Deezmaker by Qtechknow

Saturday, April 6, 13

Page 89: Intro to Arduino at Deezmaker by Qtechknow

Q&A and Project time

Saturday, April 6, 13


Recommended