Skills Infusion & Going Further: ARDUINO CLASS (/class/Arduino-Class/) : LESSON 4
Skills Infusion & Going Further: ARDUINO CLASS (/class/Arduino-Class/) : LESSON 4
f (http://www.autodesk.com)
https://www.instructables.com/lesson/Skills-Infusion/ 1/26
In this lesson, we'll cover a few important Skills
9/25/2018
concepts you'll need to understand to create
Infusion & Going Further
your own Arduino projects. We'll get up to speed on soldering, code libraries, addressable
LEDs, organizing code with functions, and calculating the power requirements of your
projects.
Supplies
To follow along with this lesson you will need:
(https://www.adafruit.com/product/145)
Tweezers (https://www.adafruit.com/products/421)
(https://www.adafruit.com/products/148)
(https://www.adafruit.com/products/275)
Soldering
https://www.instructables.com/lesson/Skills-Infusion/ 2/26
9/25/2018 Skills Infusion & Going Further
We'll use soldering to attach wires onto a piece of NeoPixel strip, so we can plug it into
the solderless breadboard. A basic soldering iron like the one recommended for this class
will take you quite far, and if you do upgrade to a temperature-adjustable soldering
station like mine, you can keep your basic iron as a spare or give it to a friend. Plug it in,
turn it on, and let it heat up for a few minutes (mine is set to 650 degrees F). Keep a damp
sponge or brass sponge nearby (many soldering iron stands come with a small sponge).
When the iron is hot, clean the tip with a few wipes across the sponge or stabs into the 3/26
https://www.instructables.com/lesson/Skills-Infusion/
brass coil sponge. Then touch the iron to your
9/25/2018
solder for a moment to transfer a little bit of
Skills Infusion & Going Further
solder to the tip, called tinning the soldering iron. Repeat this cleaning and tinning
procedure regularly while using the soldering iron to prevent buildup of excess solder and
oxidation.
Soldering works by heating up the metal components to be joined, then allowing low
temperature alloy solder to melt and ow and harden between them. Solder is not glue. If
you melt solder onto the tip and then smear it around the component leads, you will not
create a good electrical connection.
Solder is used with ux (usually built right into the solder, labeled "rosin core"), which is a
substance that helps delay oxidation. It shields the immediate area of the bonding metals,
and boils/burns away as they cool. Solder fumes are mainly tree sap, which ux is made
from. If you apply molten solder to cold components, it could potentially look soldered, but
a layer of oxidation is hidden inside, created when the solder suddenly cooled as it
touched the base component. This is called a cold solder, which prevents electrons from
owing across the solder joint. Always heat your components fully before applying
additional solder! Good solder joints will look smooth and shiny, not blobby or dull.
https://www.instructables.com/lesson/Skills-Infusion/ 4/26
9/25/2018 Skills Infusion & Going Further
A third hand tool helps immensely when it comes to stabilizing your work, especially as
you're learning to hold the iron steady. I tend to avoid caffeine around workshop time, too.
I like to put a little bit of heat shrink tubing over the jaws of my third hand tool, to soften
its bite.
Prep three of your breadboard wires by cutting off the connectors at one end and
stripping the ends to expose the bare strands of wire. Twist the strands of each wire to
keep them together, then heat up the wire with your soldering iron and apply a small
amount of solder. Remove the solder before removing the iron, to give the molten solder
one last moment to settle in. Repeat to tin your other two wires, then set them aside.
https://www.instructables.com/lesson/Skills-Infusion/ 5/26
9/25/2018 Skills Infusion & Going Further
https://www.instructables.com/lesson/Skills-Infusion/ 6/26
Cut a piece of your NeoPixel strip 19 pixels
9/25/2018
long, using your ush diagonal cutters to clip
Skills Infusion & Going Further
straight across the middle of the copper pads. Remove it from the silicone sheathing and
identify the input— the arrow markings on the strip point away from it. Clip the input end
it into your third hand tool with the back of the strip facing you. Tin the center copper pad
by touching your soldering iron to it, then applying a small amount of solder. Move your tip
around the copper pad to spread the bead of solder around.
Now that your two components are tinned, it will be easier to solder them together. Pick
up a your white wire in one hand and your soldering iron in the other. Hold the tinned wire
end to the tinned copper pad, and reheat the two components at the same time. The
solder on each should ow together, if it doesn't, you may need to apply some more.
Remove your iron before letting go of the wire, so the solder has a chance to cool,
securing the wire in place. If you nd it dif cult or too hot to hold the wire with your
ngers, use a pair of tweezers or pliers.
Flip over your NeoPixel strip and similarly tin and solder wires to the other two copper
pads (red wire for 5V, black wire for GND). It doesn't really matter which side of the
copper pad you solder to, but alternating sides gives your solder joints a little more elbow
room. Trim any excess wire protruding from the copper pad. Now you're ready to plug the
strip into your breadboard and get the LEDs glowing (we'll do that next)!
https://www.instructables.com/lesson/Skills-Infusion/ 7/26
9/25/2018 Skills Infusion & Going Further
https://www.instructables.com/lesson/Skills-Infusion/ 8/26
If you make a mistake, apply too much solder,
9/25/2018
or just want to disassemble your work, you
Skills Infusion & Going Further
can desolder the joint by simply reheating it and pulling the wire away. For more
entangled components, you can use copper desoldering braid to remove excess solder (its
highly interleaved surface area draws the solder in with capillary action), or a suction
desoldering pump.
Practice your soldering skills again by attaching wires to two diagonal leads of a
pushbutton. Tin the wires and the pushbutton leads, then reheat them to allow the solder
to ow. Set this pushbutton aside for the nal project.
https://www.instructables.com/lesson/Skills-Infusion/ 9/26
Now that the strip is soldered, we'll need to
9/25/2018
program the Arduino to turn the LEDs on.
Skills Infusion & Going Further
NeoPixel is the Adafruit brand name for WS2812 addressable "smart" LED strip (as
opposed to analog LED strip (https://www.instructables.com/lesson/LED-Strips/)). Each
pixel has a chip inside to communicate with the Arduino board and other pixels on its strip
(it can't light up without a controller). To control the strip, some additional Arduino
functions are required, and we can get them by installing the code library. Arduino code
libraries empower you to leverage powerful computing tools using simple commands.
Arduino recognizes these add-on modules and then you can use their commands within
your program. Arduino libraries exist for all sorts of complex tasks, like controlling large
LED panels, reading sensors, creating sounds, and many more.
In your Arduino software, navigate to Sketch -> Include Library -> Manage Libraries...
When the Library Manager opens, search for "NeoPixel" in the upper right eld.
Optionally select a version of the library from the dropdown menu, and click the "Install"
button. Now you're all set to use the NeoPixel library in your Arduino sketches! You can
use the library manager to install all kinds of fun extensions to the Arduino programming
language that help you interface with sensors, motors, and more.
https://www.instructables.com/lesson/Skills-Infusion/ 10/26
Take a close look at your pixel strip. Each pixel
9/25/2018
contains a very small RGB LED, which can
Skills Infusion & Going Further
theoretically create any color of light. However, generating pure white poses a challenge
for RGB LEDs and often leaves users disappointed in the tinted or poorly mixed quality of
light produced. For this reason, the RGBW strip includes a white LED inside its package
as well.
Coding for these pixels will include four brightness values to describe a pixel color: red,
green, blue, and white. This is similar to analogWrite(); in the RGB LED example from your
rst exercises: you provide a number from 0-255 to represent the brightness of the LED.
The functions in the NeoPixel library take pixel numbers and these color values as
arguments, then translate them into the commands to send along the LED strip.
Now that our NeoPixel strip has wires attached to it, let's connect it to the breadboard.
The 5V wire (red) goes to your breadboard's power bus, and the ground wire (black) goes
to the breadboard's ground bus. Connect the data wire (white) to Arduino pin 6.
https://www.instructables.com/lesson/Skills-Infusion/ 11/26
9/25/2018 Skills Infusion & Going Further
Initializing
Download/copy the code from the Tinkercad Circuits module (Code button->download
code button) and open it in your Arduino software. Plug in your USB cable and upload to
your Arduino Uno, and watch the pixels light up and change colors.
https://www.instructables.com/lesson/Skills-Infusion/ 12/26
9/25/2018 Skills Infusion & Going Further
#include <Adafruit_NeoPixel.h>
#define PIN 6
#define NUM_LEDS 19
#define BRIGHTNESS 50
https://www.instructables.com/lesson/Skills-Infusion/ 13/26
The rst section instantiates the NeoPixelSkills
9/25/2018
strip and sets up the con gurable bits of the
Infusion & Going Further
program like the pins connected to the NeoPixel strip and button, the number of pixels,
and global brightness level. #define statements are similar to variable declarations, but are
used for information that does not change while the program is running. They take up less
memory than regular variable declarations.
void setup() {
strip.setBrightness(BRIGHTNESS);
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
strip.show(); is used any time you want the pixels to change. Setting the pixel colors and
showing the latest changes are broken up into two separate commands.
void loop() {
// Some example procedures showing how to display to the pixels:
colorWipe(strip.Color(255, 0, 0), 50); // Red
colorWipe(strip.Color(0, 255, 0), 50); // Green
colorWipe(strip.Color(0, 0, 255), 50); // Blue
colorWipe(strip.Color(0, 0, 0, 255), 50); // White
whiteOverRainbow(20,75,5);
pulseWhite(5);
// fullWhite();
// delay(2000);
rainbowFade2White(3,3,1);
}
The main loop just calls other functions. Let's take a closer look at colorWipe(); , de ned just
below the main loop, and takes two arguments: a color ( strip.Color(r, g, b, w) ), and a speed
value.
https://www.instructables.com/lesson/Skills-Infusion/ 14/26
The function de nition starts with what type
9/25/2018
of data the function will return, or send back
Skills Infusion & Going Further
to the main program. In this case the function returns nothing, so the word void is used at
the start of the de nition. Next is the name of the function, which is up to you. Then in
parentheses are the arguments the function takes, in this case a 32 bit unsigned integer
called "c" and an 8 bit unsigned integer called "wait." Inside the function, these local
variables are used to reference the information you passed to it from the main loop (or
from another function). The function itself steps through all the pixels in the strip (using a
for loop and a NeoPixel function called strip.numPixels(); ), coloring and showing each one
before moving to the next. The other functions in the RGBW strandtest program work the
same way, and use clever color math to achieve stunning light patterns.
Then start playing around with the code. Say I want to light up a random pixel in the strip
instead of lighting them up in order. I could use Arduino's built-in random(); function
(https://www.arduino.cc/en/Reference/Random) to pick a pixel, which generates a random
number between the two arguments:
strip.setPixelColor(random(0,strip.numPixels()), c);
void loop() {
animationExperiment(strip.Color(255, 0, 0), 50); // Red
}
Repeatedly upload your code experimentation to your Arduino Uno board, making small
changes each time. If you nd an effect you like, stop editing that function and create a
new one, either by copying/pasting a function and changing its name, or typing out the
de nition:
https://www.instructables.com/lesson/Skills-Infusion/ 15/26
9/25/2018 Skills Infusion & Going Further
void functionName() {
//contents
}
Congrats, that's all there is to creating functions in Arduino! They're a handy tool to
separate out a chunk of code you want to access repeatedly, and make your code easier to
read.
As we touched on in the DC motor and NeoPixel circuits, it's likely you'll want to power
your Arduino project with something other than your USB cable. Whether you're building
an LED sign that plugs into the wall, or a battery-powered GPS circuit for your next
geocaching adventure, just a bit of simple math will help you pick the right power supply
every time. All you do is add up the current draw of each component, and pick a supply
that matches or exceeds your amperage needs. Components list their current draw on
product pages and datasheets. For example, 10 LEDs that each draw ~20mA, when
hooked up to an Arduino board that draws ~50mA. 10*20+50 = 250mA. A 250mAh
battery will run this circuit for one hour. The rechargeable AA pack in the picture above
provides 1900mAh, so it can power the circuit for 1900mAh/250mA = 7.6 hours. When
hooking batteries up in series, their voltage adds up but their amperage does not (4 AA
batteries is 4x1.5V but not 4x1900mAh).
In reality your circuit may use far less power than the calculated maximum. LEDs that are
dimmed with PWM only use a fraction of the power of those at full brightness, for
example. Having more current available than you need isn't a bad thing, as it helps
prevent overtaxing your supply. Circuits only draw as much power as they need!
For most Arduino projects, a 4xAA or 3xAAA pack will suf ce. You can connect directly to
the Arduino's 2.1mm barrel jack with a battery pack or wall supply, or plug the USB cable
into a wall adapter. Many smaller Arduino compatible boards have JST ports on board, a
common connector for lipoly batteries. Some even have USB charging right on the board!
Lipoly batteries have special safety concerns, so be sure not to short circuit or abuse them,
store them at extreme temperatures, and read any manufacturers' safety warnings before
working with them.
https://www.instructables.com/lesson/Skills-Infusion/ 16/26
Let's wrap up this skills infusion with a little
9/25/2018
recap quiz on what you've learned so far!
Skills Infusion & Going Further
QUIZ QUESTION 1
Choose the false statement:
Answer!
QUIZ QUESTION 2
The pins labeled Digital 0-13 on your Arduino Uno board:
Answer!
QUIZ QUESTION 3
What does a 'for loop' do?
Answer!
https://www.instructables.com/lesson/Skills-Infusion/ 17/26
9/25/2018 Skills Infusion & Going Further
QUIZ QUESTION 4
You want to make a project with 45 NeoPixels, which you intend to run at half brightness.
What power supply should you use?
2A battery or AC adapter
Answer!
Learning to Fish
(https://cdn instructables com/FGH/YLAX/J3KFAQKP/FGHYLAXJ3KFAQKP LARGE jpg)
You've made it to the end! What follows are some parting words of advice for venturing
off into the world of Arduino on your own.
Rest assured that because of its rich community history, most of your early questions
about Arduino are already well documented online in tutorials and forums all over the
web. However you are just learning the vocabulary by which to access this vast catalog of
resources, and things may be a little rocky at rst. Remind yourself there is a learning
curve, and everything will get easier and come more naturally after some time and
repeated practice. Here are some tips to improve the results of your self-directed learning.
Google with gusto - Get good at search engines! Use quotes to search for Arduino error
messages, brainstorm key words around your idea and look for folks who've documented
similar projects before. This can be handy during the parts brainstorming step but also for
learning more uses for the parts you already have. Become a regular lurker in the Arduino
(https://forum.arduino.cc/) and Adafruit (https://forums.adafruit.com/) forums, where most
beginner roadblocks are solved many times over. Say it with me: "I bet I can nd someone
online who's had this question before; I just have to nd it."
https://www.instructables.com/lesson/Skills-Infusion/ 18/26
Sharing (code) is caring - Arduino is built on
9/25/2018
open source ideas. Innovation ourishes
Skills Infusion & Going Further
Document your process - It's easy to forget to photograph your circuit before revising it
when you're in the throws of frustration over a bug. Set a timer to remind yourself to take
pictures and video while building! You may nd yourself wanting to look back at previous
iterations to avoid making the same mistakes twice. Additionally, you'll nd a supportive
community of makers willing to help you along your way if you choose to share your
projects online in forums, your own website, or here on Instructables. Documenting your
struggles along with your successes will connect you with knowledgeable folks around
the globe, and maybe even help someone else who's just learning Arduino.
Protect the power supply - The most important part of your circuit to keep safe is the
battery and power connections. A short circuit here could trip a circuit breaker,
permanently damage components, or cause a re.
Strain relief - Remember that your circuit has both mechanical and electrical connections.
Sometimes they are one in the same, like the Arduino's USB and power ports. However
it's always a great idea to add mechanical connections to your projects to prevent wires
from tugging on their solder joints. You can use zip ties to secure wires, and most circuit
boards have mounting holes for use with screws or hand sewing
(https://www.instructables.com/class/Hand-Sewing-Class/). For connections that will
bend repeatedly, use stranded wire instead of solid-core.
Know your adhesives - Using the right glue for the job is critical for your circuit's
durability! For instance, few things will actually stick to the silicone sheathing that comes
around LED strip. Only certain silicone adhesives will provide a weatherproof seal in this
case. Permatex 66B (http://www.amazon.com/dp/B0002UEPVI/?tag=instructabl09-20) is
my favorite for NeoPixel strip's silicone sheathing. Any adhesive should be tested to check
https://www.instructables.com/lesson/Skills-Infusion/ 19/26
that it bonds to both surfaces. Hot melt glue
9/25/2018
was convenient for the in nity mirror project
Skills Infusion & Going Further
in this class, but it stinks for durability. Instead I highly recommend E6000 craft adhesive
(http://www.amazon.com/dp/B0018NBWVO/?tag=instructabl09-20), or its cousin Quick
Hold. These take longer to dry but stick to everything (except silicone) and dry clear and
exible. To learn more about adhesives, check out our Glue class
(https://www.instructables.com/class/Glue-Class/)!
Humidity & moisture - It's important to protect your circuit from water, which will cause
shorts. If you're thinking of making an electronic costume, for instance, did you consider
that your evaporating sweat could be a factor? Where will your circuit be located and
what humidity/water conditions can you expect there? Generally you can think of using
coverings and coatings to address this issue. You can nd completely waterproof
enclosures for your projects, cover your circuit with waterproof fabric, and use waterproof
adhesives to seal up any openings. I often use clear nail polish to protect bare components
on costumes/wearables. Clear spray paint is also a good option, however I'm not a big fan
of the new hydrophobic coatings like NeverWet. They were designed for things like the
circuit board inside your phone, and don't function well outside that context because of
their extreme physical fragility, sensitivity to sunlight, and highly toxic nature.
However water is not a circuit's nemesis! If the battery/power supply is removed, most
circuits won't be damaged by water, so long as they dry out before being plugged back in
(and weren't left a long time to corrode). Exceptions exist for components that water can
get inside, like microphones. But generally, it's ok to hand wash your Arduino projects
after unplugging the power and removing any batteries.
UV and temperature uctuation exposure - Over time, many plastics, adhesives, and other
protective materials break down when exposed to sunlight. Wire sheathings may become
brittle and crack open. Coatings may break down and fail. Think about the temperatures
your circuit is likely to experience, too. Most batteries' lives are shortened by exposure to
high or low temperatures, for instance. Check the datasheets for your components to
learn their operating temperature ranges.
This is just the tip of the durability iceberg, folks. There are whole elds of study devoted
to the topic, in mechanical engineering, industrial design, and materials science just to
name a few. However for most projects, a bit of E6000 and some zip ties really go a long
way towards keeping your projects alive.
Next, Try...
https://www.instructables.com/lesson/Skills-Infusion/ 20/26
If you completed all the lessons in this class,
9/25/2018
you're now ready to take on countless
Skills Infusion & Going Further
Arduino projects, including your own designs. Don't know where to start? Try my Easy
In nity Mirror with Arduino Gemma (https://www.instructables.com/id/Easy-In nity-
Mirror-With-Arduino-Gemma-NeoPixels/). You may also nd many of the early code
examples to be great starting points when building your own sketches. For your next
class, consider Internet of Things (https://www.instructables.com/class/Internet-of-
Things-Class/), Electronics (https://www.instructables.com/class/Electronics-Class/),
Wearable Electronics (https://www.instructables.com/class/Wearable-Electronics-Class/),
or Robots (https://www.instructables.com/class/Robots-Class/), which will all deepen your
understanding of some of the concepts from this class.
Here are some projects from the Instructables community to help inspire your next
creation:
Have you made a project with Arduino you'd like to share? Please consider writing an
Instructable about it, and enter it in one of our frequent contests.
Thank you so much for taking my Arduino class! If you enjoyed your experience, consider
sharing it with a friend. And I'd like to receive your feedback either way, so I can improve
this and future classes.
https://www.instructables.com/lesson/Skills-Infusion/ 21/26
9/25/2018 Skills Infusion & Going Further
« Previous (/lesson/InputOutput/)
Ask a Question
about getting input from keyboard and control the program stored ?
F
More Questions
What's Next?
Finished the lesson? Here are some great projects to practice your new skills.
Easy Infinity Mirror With Arduino Gemma & DIY Art Deco Analog Thermometer Using
NeoPi... (/id/Easy-Infinity-Mirror-With-Arduino- Arduino (/id/DIY-Art-Deco-Analog-
Gemma-NeoPixels/) Thermometer-Using-Arduino/)
by bekathwia (/member/bekathwia/) by educ8s (/member/educ8s/)
Warping Infinity Mirror (/id/Warping-Infinity- The Word Clock - Arduino Version (/id/The-
Mirror/) Word-Clock-Arduino-version/)
by makendo (/member/makendo/) by drj113 (/member/drj113/)
https://www.instructables.com/lesson/Skills-Infusion/ 23/26
9/25/2018 Skills Infusion & Going Further
Secret Knock Detecting Door Lock (/id/Secret- Simple Arduino and HC-SR04 Example
Knock-Detecting-Door-Lock/) (/id/Simple-Arduino-and-HC-SR04-Example/)
by Grathio (/member/Grathio/) by jsvester (/member/jsvester/)
https://www.instructables.com/lesson/Skills-Infusion/ 24/26
9/25/2018 Skills Infusion & Going Further
https://www.instructables.com/lesson/Skills-Infusion/ 25/26
9/25/2018 Categories About
Skills Infusion & Going Further Resources
Us
Technology (/technology/) Residency
Workshop (/workshop/) Who We Program
Craft (/craft/) Are (http://www.autodesk.com/pie
Home (/home/) (/about/) 9/residency/home)
Food (/food/) Why Community
Play (/play/) Publish? (/topics/)
Outside (/outside/) (/create/) Sitemap
Costumes (/costumes/) Jobs (/sitemap/)
(/topics/Positions- Help (/id/how-to-
available- write-a-great-
at- instructable/)
Instructables/)
Contact
(/contact/)
Find Us
(http://www.instagram.com/instructables/)
(http://www.pinterest.com/instructables)
(http://www.facebook.com/instructables)
(http://www.twitter.com/instructables)
https://www.instructables.com/lesson/Skills-Infusion/ 26/26