introduction to the arduino web site: arduino is an open- source electronics prototyping platform...
TRANSCRIPT
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
What we’ll do with it:
• Communicate with it• Program it• Interface to it• Build on it
• Learn to love it!
Communicate
• Single USB cable– Provides power (5V) and coms
Communicate
• Install their software: arduino.cc/en/main/software
• This is an “IDE”: Integrated Development Environment– Text editor– Compiler– Loader– helper
Interface to it
• The software works on PC’s and Macs
• You won’t do anything without this software
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
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
• 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
• 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.
• 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
• 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
Project #1: a blinking LED
• We’ll let you cheat and use the breadboard sheet! But only for this one. You have to figure out the rest yourself.
• 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
• Modify the program:– Change blinking rate– Blink two that alternate– Change intensity (this uses the pulse width
modulation)
• Project #2: Run a motor– Requires a transistor to provide more power– Use the schematic; why is the diode there?