introduction to the arduino web site: arduino is an open- source electronics prototyping platform...

23
Introduction to the Arduino • Web site: http://www.ardui no.cc/ • Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and

Upload: jean-randall

Post on 12-Jan-2016

250 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Introduction to the Arduino Web site:   Arduino is an open- source electronics prototyping platform based on

Introduction to the Arduino

• Web site: http://www.arduino.cc/

• Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software

Page 2: Introduction to the Arduino Web site:   Arduino is an open- source electronics prototyping platform based on

What we’ll do with it:

• Communicate with it• Program it• Interface to it• Build on it

• Learn to love it!

Page 3: Introduction to the Arduino Web site:   Arduino is an open- source electronics prototyping platform based on

Communicate

• Single USB cable– Provides power (5V) and coms

Page 4: Introduction to the Arduino Web site:   Arduino is an open- source electronics prototyping platform based on

Communicate

• Install their software: arduino.cc/en/main/software

• This is an “IDE”: Integrated Development Environment– Text editor– Compiler– Loader– helper

Page 5: Introduction to the Arduino Web site:   Arduino is an open- source electronics prototyping platform based on

Interface to it

• The software works on PC’s and Macs

• You won’t do anything without this software

Page 6: Introduction to the Arduino Web site:   Arduino is an open- source electronics prototyping platform based on

Program

• Arduino calls their programs “Sketches”• These are lists of commands that the Arduino

will execute• There are lots of sample sketches available

online for download and modification• Once in the IDE,

the sketch is uploadedto Arduino

Page 7: Introduction to the Arduino Web site:   Arduino is an open- source electronics prototyping platform based on

Program

• The program consists of two parts (I have no idea why they use “void”):

• 1) the setup– Establish what hardware will be used– Initialize variables

• 2) the executables (loop)– Controls– Outputs– Inputs– storage

Page 8: Introduction to the Arduino Web site:   Arduino is an open- source electronics prototyping platform based on
Page 9: Introduction to the Arduino Web site:   Arduino is an open- source electronics prototyping platform based on
Page 10: Introduction to the Arduino Web site:   Arduino is an open- source electronics prototyping platform based on
Page 11: Introduction to the Arduino Web site:   Arduino is an open- source electronics prototyping platform based on

• There are several ways to make conditional branches/loops:– If else (like the BASIC IF/THEN) but uses {} for the

“then”– For (similar to BASIC FOR) but different syntax

Page 12: Introduction to the Arduino Web site:   Arduino is an open- source electronics prototyping platform based on

• We can interface using both digital or Analog inputs/outputs– PinMode sets a pin to input or output– digitalWrite sets the output high or low (1 or 0)– Int digitalRead returns a 0 or 1 depending on

whether the input is high or low– It’s important to define the role before using the

“digital” commands and don’t cross them.

Page 13: Introduction to the Arduino Web site:   Arduino is an open- source electronics prototyping platform based on

• For anything that provides a varying voltage as it’s signal, you’ll need an analog input

• 0-1024 for normal analog; how many bits is the A/D converter?

• It can also do a pseudo analog output (0-5V) using “pulse width modulation”; pretty clever

Page 14: Introduction to the Arduino Web site:   Arduino is an open- source electronics prototyping platform based on
Page 15: Introduction to the Arduino Web site:   Arduino is an open- source electronics prototyping platform based on
Page 16: Introduction to the Arduino Web site:   Arduino is an open- source electronics prototyping platform based on
Page 17: Introduction to the Arduino Web site:   Arduino is an open- source electronics prototyping platform based on
Page 18: Introduction to the Arduino Web site:   Arduino is an open- source electronics prototyping platform based on

• Please try to avoid clipping the leads on anything!

• If they are the same on the LEDs, you can’t tell the + from the –

• Bending is okay

Page 19: Introduction to the Arduino Web site:   Arduino is an open- source electronics prototyping platform based on

Project #1: a blinking LED

Page 20: Introduction to the Arduino Web site:   Arduino is an open- source electronics prototyping platform based on

• We’ll let you cheat and use the breadboard sheet! But only for this one. You have to figure out the rest yourself.

Page 21: Introduction to the Arduino Web site:   Arduino is an open- source electronics prototyping platform based on

• Here is the code; let’s look it over:– Comment section is a great idea– Define the pin– Turn it on; turn it off; repeat, repeat, repeat

Page 22: Introduction to the Arduino Web site:   Arduino is an open- source electronics prototyping platform based on

• Modify the program:– Change blinking rate– Blink two that alternate– Change intensity (this uses the pulse width

modulation)

Page 23: Introduction to the Arduino Web site:   Arduino is an open- source electronics prototyping platform based on

• Project #2: Run a motor– Requires a transistor to provide more power– Use the schematic; why is the diode there?