PLAY PODCASTS
Learn Programming and Electronics with Arduino

Learn Programming and Electronics with Arduino

61 episodes — Page 1 of 2

Arduino Course for Absolute Beginners 2nd Edition

Aug 29, 20173 min

What is Arduino?

Have you seen some really cool stuff being made with a thing called Arduino? What is Arduino anyway? It sounds like an Italian sandwich with extra cheese or something... Well - it's that and a lot more. I hope this video can help explain some the basic premise of the Arduino!

Apr 28, 20174 min

How to change the font color in the Arduino IDE

Have you ever wanted to change the font color in the Arduino IDE? Maybe it is hard for you to read the light grey comments in the Arduino IDE, or maybe you prefer something a little bolder. Whatever your reason, in this short video, I demonstrate a relatively easy way to change the font color of comments.

Apr 27, 20174 min

Use Serial.print() to display Arduino output on your computer monitor: Part 2

In many cases while using an Arduino, you will want to see the data being generated by the Arduino. One common method of doing this is using the Serial.print() function from the Serial library to display information to your computer's monitor. In this week's episode we will talk about the intricacies of the Serial.print() function. This is the second part of a two part series on the Serial.print() function (Click here for the first part). Here are the exact topics we will cover in this lesson: Adjusting the number of digits to be displayed after the decimal point with the Serial.print() function. Adjusting the format to display with the Serial.print() function Formatting the output with text and tabs If you enjoyed this video, you should consider signing up for our free Arduino Crash Course - it has 19 high quality video training classes to help build your imagination with Arduino.

Apr 26, 20176 min

Use Serial.print() to Display Arduino output on your computer monitor: Part 1

In many cases while using an Arduino, you will want to see the data being generated by the Arduino. One common method of doing this is using the Serial.print() function from the Serial library to display information to your computer's monitor. In this week's episode, we will talk about the intricacies of the Serial.print() function. This is the first part, of a two part series on the Serial.print() function. Here are the specific topics we will cover in this lesson: Why would you want to use the Serial.print() function? A brief overview of the Serial library The basic use of the Serial.print() function Like this video? Sign up for our FREE Arduino Crash Course to get more videos that don't assume you have a PhD. Why Would You Want to Use the Serial.print() Function? You may know that a function is a programming tool - it performs a specific task for you. The Serial.print() function's task is to send information from your Arduino to your computer, so you can see the value displayed on your computer's monitor. There are an endless number of reasons you may want to send information from the Arduino to a computer display, but two reasons really stand out to me: The first reason is being able to see information that you are generating with your Arduino. For example, if you have a temperature sensor hooked up to your Arduino and you want to see the value that the temperature sensor is recording, then you can use the Serial.print() function to send the data to a computer monitor via the USB cable. If you open up the serial monitor window (Tools > Serial Monitor), you will see the values streaming in from the Arduino. The other big reason to send information to a computer display using the Serial.print() function is for developing and debugging Arduino sketches. Very often, when you are developing an Arduino sketch, what you end up coding does something differently than what you expected it to do. Maybe you have a variable that gets incremented every so often and blinks an LED when it reaches a threshold. When you upload the code to the Arduino, you notice that the LED is blinking more often than it should. You can look at the code until your eyes bleed, but actually visualizing the variable being incremented [via the Serial.print() function], to see its values every time through the loop() can help explain what is happening very quickly. A Brief Overview of the Serial Library We can't talk about the Serial.print() function, without briefly talking about the Serial library. Generally speaking, a library is simply a collection of functions that all have something in common. The print() function is part of a library called the Serial library. Now, it's not cereal like Cheerios or Captain Crunch we're talking about - it's serial as in "one after another". The serial library allows us to interface the Arduino with other hardware, like a computer. In order for us to use the functions of the Serial library, we have to initiate serial communication - to do this we use the Serial.begin() function. Serial.begin() needs to go in the setup(). void setup() { //Initiate Serial communication. Serial.begin(9600); } Now for reasons beyond the scope of this discussion, it is convenient to use the number 9600 in the Serial.begin() function. The value 9600 specifies the baud rate. The baud rate is the rate at which information will pass from the Arduino to the computer, or in the other direction. The Basic Use of the Serial.print() Function Let's talk about how to use the Serial.print() function. Say we have a sketch. This sketch has a variable called coolFactor. I want to be able to monitor the value of the coolFactor variable – that is, I want it displayed on my computer screen. A perfect use for the Serial.print() function! The first thing we must do in the Arduino sketch is begin serial communications. Like we just said, we use the Serial.begin() function and place it within the setup() of the sketch. //A variable to hold the level of coolness int coolFactor = 3; void setup() { Serial.begin(9600); } void loop() { //Send the value of coolFactor to the the Serial port. //So we can see it in the serial monitor window Serial.print(coolFactor); } Now in the loop(), if I want to display coolFactor's value with print(), I simply type Serial.print() and in the parenthesis I type the variable name. If we upload this sketch to the Arduino, the value of coolFactor will be sent to the serial port every time through the loop(). In the Arduino IDE, if you open up the serial monitor window [Tools > Serial Monitor], you will see the values streaming down. In next week's episode, we'll talk about some more intricacies of the Serial.print() function. If you enjoyed this lesson, I welcome you to join 1000's of students who have enjoyed our free Arduino Crash Course - it's a 19 part video training series on using Arduino (You can sign up below).

Apr 25, 20178 min

How to make a secret knock detector to trigger anything with only an Arduino and a few cheap components

There are a couple good use-case scenarios for making a secret knock detector using an Arduino. You are a spy who needs to authenticate your cohorts You are a super hero who wants a secret knock to open the entrance to your lair Whatever the reason - by the end of this tutorial you will know how to use an Arduino, a piezo transducer and a couple other cheap components to make secret knock detector. Here is an overview of exactly what we will talk about in this lesson: The components you will need and how to set up this simple circuit. The concept of operation of this secret knock detector A thorough description of each block of code in the Arduino sketch Why North American grizzly bears love piezo transducers For this secret knock detector circuit you need: Arduino (I use the Arduino Uno) [1] Solderless breadboard [1] 1 Mohm Resistor [1] Piezo transducer (aka buzzer) [1] Jumper wires [4] 5.1V Zener diode (for extra protection) [1] No spill stopper for a "to-go" coffee cup How to set up the Circuit: This is a really simple circuit to setup, below are step-by-step instructions and a breadboard diagram. Place the piezo transducer on the breadboard, with the positive lead and the negative lead on separate rails. Connect the positive lead to pin A0 on the Arduino and the other lead to ground. Finally, use the 1Mohm resistor to connect the leads of the piezo transducer. As an additional level of protection, you might consider adding a 5.1V zener diode between the leads to protect against high voltage spikes from frying your input pin - you might call it a cheap insurance policy. An Overview of this Secret Knock Detectors operation Here is the basic concept of how this will work. We want something to happen when you tap out a secret code. We will create a sequence of soft and hard taps - this will be our secret code which will be represented as 0's and 1's in an array. For example: secretKnock[secretKnockLength] = {0, 0, 1, 0}; The code above represents a secret code of soft , soft , hard, soft . The piezo transducer will turn the mechanical pressure created by the tap into a signal that the Arduino analog pin can read. The level of the signal will determine whether a tap gets characterized as soft or hard. The threshold of a soft vs hard tap need to be determined empirically, once you have the circuit built - it will depend on what you have the piezo transducer attached to - I have mine taped to a piece of paper. You should start with the default threshold values provided in the sketch and change them to suit your specific setup. Once a tap signal is picked up by the Arduino, the sketch will compare the entered sequence of taps to the secret code, one tap at a time. If the code is entered correctly, then we will trigger an action on the output pin. In this code below, we trigger an LED to turn on for a couple seconds - but you could trigger a servo arm, a pump, or whatever you might need. If the code is entered incorrectly - nothing happens. Here is the code for your hacking enjoyment: /* A simple sketch to detect a secret knock using a piezo transducer Created JUL 2015 by Michael James http://www.programmingelectronics.com/ This code is in the public domain */ const int outputPin = 6; // led indicator connected to digital pin const int knockSensor = A0; // the piezo is connected to an analog pin const int thresholdHIGH = 150; // threshold value to decide when the detected knock is hard (HIGH) const int thresholdLOW = 120; // threshold value to decide when the detected knock is gentle (LOW) const int secretKnockLength = 4; //How many knocks are in your secret knock /* This is the secret knock sequence * 0 represents a LOW or quiet knock * 1 represents a HIGH or loud knock * The sequence can be as long as you like, but longer codes increase the difficulty of matching */ const int secretKnock[secretKnockLength] = {0, 0, 1, 0}; int secretCounter = 0; //this tracks the correct knocks and allows you to move through the sequence int sensorReading = 0; // variable to store the value read from the sensor pin void setup() { //Set the output pin as an OUTPUT pinMode(outputPin, OUTPUT); //Begin Serial Communication. Serial.begin(9600); } void loop() { // read the piezo sensor and store the value in the variable sensorReading: sensorReading = analogRead(knockSensor); // First determine is knock if Hard (HIGH) or Gentle (LOW) //Hard knock (HIGH) is detected if (sensorReading >= thresholdHIGH) { //Check to see if a Hard Knock matches the Secret Knock in the correct sequence. if (secretKnock[secretCounter] == 1) { //The Knock was correct, iterate the counter. secretCounter++; Serial.println("Correct"); } else { //The Knock was incorrect, reset the counter secretCounter = 0; Serial.println("Fail - You are a spy!"); }//close if //Allow some time to pass before sampling again to ensure a clear signal. delay(100); //Gentle knock (LOW) is detected } else if (sensorReading >= thresholdLOW) { //Check to see if a Gentle Knock matches t

Apr 24, 201712 min

Arduino Pseudo Random Non-Consecutive Number Generator

In this video we demonstrate how to create pseudo random numbers with Arduino - with a useful twist. This lesson was inspired by the following viewer question: How do I create Random Non-Consecutive numbers with Arduino? P.S. These are the best tutorials that a complete idiot like you could ever make, thanks. -Chris Let's overview exactly what we will talk about in today's episode: Talk about pseudo random numbers. Identify the problem - using an Arduino sketch to demonstrate. Discuss how we might solve the problem. Write an Arduino sketch that solves the problem. Review what we talked about. Before we answer the viewer's question it is important to talk about what a pseudo random number is. A purely random number in the mathematical sense can't be predicted. The microcontroller that the Arduino uses (and for that case, most computers in general) can't really create pure random numbers. What they create instead are called pseudo random numbers. These are numbers that appear to be randomly generated, but if studied over time a predictable pattern emerges. The bottom line is that the random numbers we create with Arduino can be predicted. Now there are clever ways to create pseudo random numbers that act like the real deal – you can learn about one method in our video tutorial talking all about random numbers – but for this discussion, let's return to our viewers inquiry. Identify the Viewer's Problem - use an Arduino sketch to demonstrate. Ok, so let's go back to the viewers question, he wants to generate random numbers, but he never wants the same number generated two times in a row. Let's write an Arduino Sketch to make this clear. //This sketch outputs pseudo random integers. //A variable to hold pseudo random integers. int randomInt = 0; void setup() { //Initiate serial communication. Serial.begin(9600); }//Close setup function void loop() { //Create a random number and assign it to the randomInt variable. randomInt = random(0, 10); //Send randomInt to the serial port for displaying on the serial monitor window. Serial.print(randomInt); }//Close loop function. In the first block of code a variable that will hold the pseudo random integers is declared and initialized. //A variable to hold pseudo random integers. int randomInt = 0; In the setup() function we begin serial communication in order to display the numbers we generate on a computer display. void setup() { //Initiate serial communication. Serial.begin(9600); }//Close setup function In the loop() we create the random number with the Arduino random() function and assign the output to the variable we had just created. The random() function can take two arguments 1) the minimum value of the number we want generated 2) the maximum value we want generated. //Create a random number and assign it to the randomInt variable. randomInt = random(0, 10); I will use 0 for the minimum, and 10 for the maximum. Every time through the loop, a new random number will be assigned the randomInt variable. Finally, the value of randomInt is sent over the serial port to be displayed in the serial monitor window. //Send randomInt to the serial port for displaying on the serial monitor window. Serial.print(randomInt); If you upload this code and open the serial monitor you will see in some cases where the same number shows up two times in a row. This is the problem. The viewer doesn't ever want the same number two times in a row. Discuss how we might solve the problem. So let's talk about how we might solve this problem. We know we need to generate a random number. What if we create a variable to track the previous random number? Then we could use a condition that says something like "If the previous random number is equal to the random number that was just generated, toss that number out the window, and create a different one." The final thing we would need to do is set the previous random number equal to the new random number, that way we keep updating our previous random number every time through the loop(). Let's Implement our solution in an Arduino Sketch. Copy and paste this code into your Arduino IDE. All you need is an Arduino board attached to your computer to make it work. //This sketch outputs pseudo random non-consecutive integers. //A variable to hold pseudo random non-consecutive integers. int randomInt = 0; //A variable to hold the previously assigned pseudo random non-consecutive integers. int previousRandomInt = 0; void setup() { //Initiate serial communication. Serial.begin(9600); }//Close setup function void loop() { //Create a random number and assign it to the randomInt variable. randomInt = random(0, 10); /*Check if the random number is the same as the previous random number. If it is, then reassign a new random number until it is different from the previously set one.*/ while (randomInt == previousRandomInt) { //Create a random number and assign it to the randomInt variable. randomInt = random(0, 10); //When a consecutive random number has been identi

Apr 23, 201711 min

A Review of Make: Magazine

I don't subscribe to many magazines, but I love my subscription to Make: magazine. And even though I rarely have time to sit down and enjoy a magazine in peace and quiet (parents forget what peace and quiet means), I still manage to get through my Make: magazine cover to cover. I like it that much! This video is a short review of why I enjoy Make: magazine, and why I think you would enjoy it too. Here are some highlights: 1. Make: Magazine is published every 2 months. 2. Filled with detailed step-by-step projects 3. Has interesting editorial articles about technology 4. Covers a lot of hobby electronics topics (like Arduino) 5. Has sections dedicated to skill building Total Honesty: Nobody paid me to make this review of Make: magazine. I made this video because I personally enjoy the content and rigor and think you might like it too. That being said - if you are interested in subscribing to Make: magazine I would love for you to use the link below if you so choose: Click Here to Check Out Make: Magazine The above is an affiliate link. At no additional cost to you, I get a kick back from subscriptions that originate from the link. This cash allows me to furnish my mansion in downtown Manhattan, make necessary repairs to my yachts, and fuel the Lamborghini for joy rides. Do you subscribe to Make: magazine? I would love to hear your thoughts in the comments.

Apr 22, 20178 min

Understanding the Arduino Sketchbook: Opening and Saving Arduino Sketches

Understanding how the Arduino IDE sets up its file directory system can spare you some confusion when it comes to saving, organizing and opening your Arduino sketches (or sketches you have downloaded from the internet). This week's episode covers the following: The Arduino Sketchbook folder How to change the default location where your Arduino sketches get saved What happens when an Arduino file does not have an enclosing sketch folder of the same name Where and how multiple tabs get saved in an Arduino sketch Why the pancreas of a woodchuck is better suited than our own Want to fast-track your Arduino skills? Click here to join our 12-part HD Video Course. You are probably familiar with a file directory system on a computer. It's usually represented as a hierarchy of folders and files. An example would be your C Drive - inside the C drive, you may have a folder for Applications, Users, and Systems files. Inside the Users folder, you might have subfolders for Documents, Downloads, Music, etc. All the files on the computer get organized in this fashion, and Arduino sketches are no exception. The Arduino Sketchbook Folder and Changing the Default Save Location The default location where Arduino sketches you write will be saved is called the Sketchbook. The Sketchbook is simply a folder on your computer like any other. It acts as a handy repository for sketches and is also where add-on code libraries get saved. You can see the sketches in the Sketchbook folder by going to File > Sketchbook. The default name of the Sketchbook folder is "Arduino" and the default location of the Sketchbook folder is in the "My Documents" folder (or just "Documents" for Mac users). If your Sketchbook does not appear to be in this default location, you can see exactly where it is by opening the Arduino IDE and going to Arduino > Preferences. The default file path for your sketches is listed at the top of Arduino Preferences window. Mine is: /Users/michaelJames/Documents/Arduino When I save a file in the Arduino IDE, this "Arduino" folder is the default location where the sketch will be saved, unless I choose to change that location by selecting a different folder on my computer's directory. If you want to change this default location, you click the Browse button next to the file directory path and choose a different place. Pretty simple. Sketch Folders If you go into your file directory system and open up the Sketchbook folder (again, named "Arduino" by default), you may see a bunch of folders that you didn't make. This is because every Arduino file must be inside a folder that has the same name as the file (there are some exceptions to this that we'll talk about in a moment). Let me say that one more time because it is really important to understand. Every Arduino file must be inside a folder that has the same name as the file When I write a new sketch and save it, the Arduino IDE automatically creates a new folder that has the exact same name as the sketch itself. The Arduino file (which has the extension .ino) is placed inside this enclosing folder, which is called a sketch folder. If you go into the Sketchbook folder and change the name of the enclosing folder, it will create some issues. The first issue is that when you go to File > Sketchbook, the sketch will no longer show up! If you want to open this sketch you need to go to the .ino file in your directory and open it from there. If you open a .ino file that is not inside an enclosing sketch folder of the exact same name, then you will get a pop-up from the Arduino IDE that says: "The file "sketch_name.ino" needs to be inside a sketch folder named "sketch_name". Create this folder, move the file, and continue?" If you choose Cancel, the sketch will not open. If you choose OK, then a folder gets created (it will have the same name as the sketch) and the .ino file is placed inside it. This sketch folder will be created in whatever directory the .ino file was that you tried to open. For example, if you tried to open a .ino file that was in your My Downloads folder, then the enclosing sketch folder also will be created inside the My Downloads folder. Saving Tabs in Arduino The exception to the rule about the sketch folder having the same name as the .ino file is when you create multiple tabs in an Arduino sketch. The additional tabs do NOT need to bear the same name as the enclosing sketch folder. Once you get a handle on some of these intricacies of the Arduino IDE file system, it can really help to clear things up. Please take a moment to leave a comment if you have any insights or thoughts about this tutorial. I would love to hear them!

Apr 21, 20179 min

An Easy Way to Learn I2C, SPI, RTC, ADCs and More with this Awesome Arduino Education Shield

In this video we talk about an Arduino shield designed to teach you about shift registers, I2C, SPI, temperature sensors, real time clocks, analog to digital convertors and flash memory chips - all this on one awesome Arduino shield! Electronics Concepts can be Intimidating Like any industry or hobby, electronics has its fare share of acronyms. A couple of the more common ones you might have come across are SPI, I2C, ADC, RTC and YOMAMA. All these acronyms can be intimidating. It's like this giant lion staring you down. You can spend a lot of time reading about each of these concepts, buying a bunch of different parts and working up breadboards - this is a great way to learn – it's kind of the common path many hobbyist and professionals have taken alike. But if you want to grab the lion by the throat - I would like to introduce you to my new favorite Arduino shield. The Rheingold Heavy Education Shield. It's an Arduino shield designed to teach you about the ins and outs of all these really common electronics concepts (like I2C and SPI) and applying that understanding to hardware (like analog to digital convertors and Flash RAM). It's not just the shield that makes this an education board, it's all of the really thorough documentation and tutorials that accompany the hardware on the Rheingold Heavy website. Have Fun Learning Electronics If you are going to learn electronics, you might as well have fun doing it. That's one great thing about the Rheingold Heavy tutorials - they are fun - the author has a great sense of humor and keeps things real. He does a great job at demystifying electronics concepts that on the outside seem extremely complex, but dissected piece by piece can be made elementary. I would say my favorite part about the tutorials is the depth and detail they cover. I think this line from one of the introductory tutorials captures the style of the author… ...I don't like "just making it work" — I want to know why it works the way it does. Hardware and Education Unite The real magic happens when you have the Education Shield and start working through the tutorials. The lessons on the Rheingold Heavy website are all designed step-by-step to walk you through understanding in detail the hardware on the shield. The lessons are a good length, focus on just a couple concepts at a time and get into the nuts and bolts. The Rheingold Heavy Education Shield itself is jam packed with components. It's got a shift register hooked up to 8 surface mount LEDs for learning about shift registers, a real time clock, a temperature sensor, a 10 bit analog to digital convertor, and 8Mbytes of Flash RAM. All this hardware you learn to use with either I2C protocol or SPI! It's like an electronics learning laboratory on a single Arduino shield. If you already have a handle on some of these concepts, and you don't think you need the whole shield, you can purchase breakout boards for each separate component and all the documentation on the website works equally well for those. I know I've said it once, but it deserves saying again - the tutorials are written in a fun and relaxing tone - with tons of diagrams, questions along the way to make sure you're on track and Arduino code to help experiment with the shield and concepts. History of the Rheingold Heavy Education Shield The brainchild of this education shield is Dan Hienzsch. In 2014 he ran a successful Kickstarter campaign that brought these shields to fruition. After successfully fulfilling all his Kickstarter backers (and on time!) he has set up shop and is now churning out these education shields all over the world. My Unabashed Endorsement I am just little biased towards this education shield - I know Dan - he's a great guy and very passionate about what he does. After buying the shield and the breakout boards and working through the tutorials on the website I have learned a ton! The best part is how much fun it has been to work through the material. I love learning and if I can have a single "aha!" kind of moment everyday, then I sleep at night pretty good. My experience with the Rheingold Heavy Education Shield has brought me these moments left after right. Needless to say I highly recommend this Arduino shield to any body who wants to get a solid and detailed grasp of concepts like SPI and I2C, or about using real time clocks, analog to digital convertors, temperature sensors, shift sensor and a whole lot more. With all this education packed into Rheingold Heavy Education Shield, backed-up with really enjoyable tutorials, you can't go wrong.

Apr 20, 20175 min

The Process and Tools I use for Creating Arduino Tutorials

This week's Episode is what I am calling an intermission, which is basically me taking a break from hardcore Arduino tutorial making, and present a less technical topic. In this intermission video, I walk through the process I use when creating Arduino tutorials and some of the software that helps me do it. Here is a list of software I use when creating Arduino tutorials: Full Disclosure: Some of these are affiliate links that help me afford gold toilets on my private island. Brainstorming/ Mindmapping software (mac): MindNode Simple Text Editor (mac): TextMate Screen Capture software: Camtasia for Mac Audio Editing: Audacity Circuit Design: Fritzing More Robust Text Editor: Microsoft Word for Mac If you want to check out some of our best Arduino tutorials, sign up for our free Arduino Crash Course below.

Apr 19, 20178 min

Using the Same Input to Trigger Multiple Arduinos

If you ever have a project using two or more Arduinos, it's likely you'll want them to work together. Say for example you have one Arduino connected to an LCD shield, and another Arduino controlling an LED matrix. You want both to do something when you press a single button - how can this be done? It turns out to be extremely easy. This video will describe in detail how to trigger multiple Arduinos with a single input. CODE: /* Button Turns on and off a light emitting diode(LED) connected to digital pin 13, when pressing a pushbutton attached to pin 2. The circuit: * LED attached from pin 13 to ground * pushbutton attached to GND through pin 2 on two (or more) Arduino's * Note: on most Arduinos there is already an LED on the board attached to pin 13. created 2005 by DojoDave modified 30 Aug 2011 by Tom Igoe Modified 16 APR 2015 by Michael James https://programmingelectronics.com/using-the-same-input-to-trigger-multiple-arduinos/ This example code is in the public domain. http://www.arduino.cc/en/Tutorial/Button */ // constants won't change. They're used here to // set pin numbers: const int buttonPin = 2; // the number of the pushbutton pin const int ledPin = 13; // the number of the LED pin // variables will change: int buttonState = 0; // variable for reading the pushbutton status void setup() { // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); // initialize the pushbutton pin as an input: pinMode(buttonPin, INPUT_PULLUP); } void loop() { // read the state of the pushbutton value: buttonState = digitalRead(buttonPin); // check if the pushbutton is pressed. // if it is, the buttonState is HIGH: if (buttonState == LOW) { // turn LED on: digitalWrite(ledPin, HIGH); } else { // turn LED off: digitalWrite(ledPin, LOW); } } Breadboard Layout: Downloads: Schematic Fritzing File.fzz If you like this tutorial, check out some of out very best by signing up for our free Arduino Crash Course below.

Apr 18, 20179 min

6 Tips on Assembling an Arduino Shield (Or any Electronics Kit)

In this video we will be talking about some key points to keep in mind when assembling an Arduino shield from a kit. Many of these tips will apply equally well to any type of electronics kit you are assembling. So you just bought an awesome Arduino shield - it's going fly you to the moon and back, but before you start using it you have to do some basic assembly. Here are six tips to help you get the assembly done right the first time. Read the Directions: The first advice is painfully obviously, but still worth mentioning - read the directions! When all you have to do is solder on some pin headers and a couple LEDs, it's tempting to ignore the need for directions and just go at. You're a genius right - who needs directions? As J.R.R. Tolkien said... "Shortcuts make for long delays". Even on simple assemblies it pays to take the time to read through the directions. Most companies keep the directions online – they are really only a search away. I'm telling you it's worth it! Consider Where you Will be Assembling the Board: You may not have a dedicated space for your electronics addiction. There have been many times when I find myself soldering stuff on my kitchen table. If you don't have a dedicated space, a couple things you will want to consider are: • Having good lighting, so you can see what you are up to • Access to a wall outlet for your soldering iron – you want the cord to have some maneuver room • A floor without shag carpet, as they tend to be repositories for small electronics parts (the smallest parts are always the first to fall) You can't always have the best spot, but you can make the best of what you have available. Get Your Tools Together Good instruction manuals will let you know what tools you need for the job. Generally speaking, the essential tools are: • soldering iron • solder • wire cutters Some other tools that are not necessary but make life way easier are: • Needle nose: pliers for grabbing tiny parts • Helping hand: these help not only holding parts when soldering, but also provide the magnifying glass which is good for checking solder joints • Solder wick for undoing your mistakes • A pair of safety glasses is also a good idea. You might be thinking – ah, heck with safety glasses… It's easy to write them off when assembling boards. What I have done is get a pair that is comfortable and that I keep clean - this makes using them less a hassle. It's a small precaution to take from getting a piece of tiny sharp metal in your eye. Inventory All the Parts For whatever reason, inventorying all the parts always seemed like a waste of time to me, but now it is something I make sure to do. Two big reasons I do this. Many of the boards I get are from Kickstarter campaigns, so the people manufacturing these might be kind of new at the gig, and with all the stuff they have going on, it's very possible they missed a part in the package. Another reason I like to do the inventory is so I know if I have extras. If I have pieces left over when I finish, then I am usually wondering if I did the assembly correct or not. If you do the inventory, then you can be confident that you assembled it right. I also separate the components into different jars, or bowls. This helps me quickly find components when I am assembling the shield and prevents the pieces from ending up lost in the carpet. Check Twice Solder Once I like solder wick as much as the next guy, but I would prefer not use it. It is really worth your time to double check part locations before you start soldering. I learned my lesson when I soldered a 24 pin connecter on the wrong side on a board. Now I always check a diagram or the directions at least twice before pulling out the solder. After I solder, I also make it a point to look over the solder joints. I am amazed at how much my soldering joints can stink, even when I feel like I had done a great job (this is when a helping hand or magnifying glass is good to have). Use an Arduino Board to Help Align the Pin Headers. One thing all Arduino Shields have in common are pin headers. These are the metal rows of pins that go on the bottom of the shield and plug into the Arduino stackable headers. If you don't get the pin headers aligned correctly then your shield may not fit well, or may not fit at all on top of the Arduino. One trick to get the alignment right is to use an Arduino to hold the pin headers in the correct position when you solder them to the bottom of the shield. To do this, simply insert the headers how they would go into the Arduino, place the shield on top, and then do your soldering. It works like a charm. Troubleshooting the Assembly Now that your Arduino shield is fully assembled, it's time to get that puppy running. Hopefully the shield came with some type of test sketch that you can load and it verifies that everything is up and running correctly. If not, try to find some code that you know works and load it onto the Arduino. If you start with code that you can verify works

Apr 17, 20178 min

A YouTube Channel for Learning about Arduino

In this episode I talk about the video channel that I host on YouTube. If you have watched any previous episodes of this channel then you know I focus on Arduino related topics. The purpose of the channel is to help people learn about using Arduino. Specifically, the target audience is electronics hobbyists who are interested in learning to use Arduino. That being said, I try to make the videos from the perspective of a beginner so if you don't know jack about electronics or programming, then the show should still be a great place for you to learn.Every Tuesday I will be releasing a new episode. Every fourth video will be something like the video shown above. The reason I am doing this is because it gives me a little bit of a break in video production, which is extremely time consuming. I am calling these types of videos "Intermissions" which is all I could come up with. So this is the first intermission video (and post). A Little Bit About Myself: I am an electronics hobbyist - I've be messing around with hobby electronics for a about a decade, and I have been learning about Arduino for a big part of that time. I don't have any formal training in electronics so the perspective you get from me might be a lot like you, someone who has tried really hard to learn about electronics with as much spare time as I could find between work, family, and the curve balls of life. I do have some formal training in programming (though not much). I took a C++ course in college and used Matlab for some research I was doing at the university. What type of topics can you expect to watch on this video channel? Like I said before this channel is focused on Arduino - but there so many applications for Arduino it gives me a bunch of latitude for all types of stuff. There will be a ton of "how to" tutorials. Not about cutting and pasting the code – they'll be about understanding how to make your own code. I'll talk about Arduino derivatives, shields and cool hardware and sensors you can use. I am really interested in science, so I plan to start doing some videos on using Arduino to enable Citizen Science. I might start with some data logging ideas. Student Projects: On a quick aside, what I do for a living is run an online course that uses a very structured curriculum to teach electronics hobbyists how to use Arduino. The Arduino Course is designed so you don't need any electronics background to work through it, but I find most of my students do have some electronics experience to begin with. The reason I bring this up is because many of the students submit projects they are working on and I plan to use these "intermission" videos to show off some of the stuff they have done. For example, James (a really quick study) who took the course has been making all types of cool Laser tag accessories using Arduino. Which is pretty awesome - and very impressive. Projects I am Working on: I will also use these "intermission" videos to talk about some of the projects I am working on. Lately, I have been thinking about a little robot that can draw. I only really work on it when my kids are around, so the progress is painfully slow. What I would really like is to get the robot to draw sketches of people. No idea if I will ever make it to that point (or how the heck I am going to pull it off), but it's my pet project that I have been working on. So that's it for this first intermission post (and video). I will see you in the next show, where we will be talking more things to consider when assembling Arduino Shields from kits. Until then! If you are interested in learning how to use Arduino, sign up for our free Arduino Crash Course below.

Apr 16, 20175 min

What is a Breakout Board for Arduino?

If you have been learning about Arduino for any amount of time, than you have probably come across the term Breakout Board. Now, you might think, as I did when I first heard about breakout boards, that they were some fixture for practicing your Kung Fu fighting. In this lesson, we will discuss what breakout boards are, how they can accelerate your Arduino prototyping and some things to look out for when you buy them. Want to step-up your Arduino skills? Click here to join our 12-part HD Video Course. Basic Concept of a Breakout Board The basic concept of a breakout board is that is takes a single electrical component and makes it easy to use. Usually the electrical component is an integrated circuit (IC). Integrated circuits, as you may know, have pins on them. The pins on an IC can do a multitude of things, but you usually have pins for supply power, pins for providing a ground, pins for receiving an input and pins for sending an output. A breakout board "breaks out" these pins onto a printed circuit board that has its own pins that are spaced perfectly for a solderless breadboard, giving you easy access to use the integrated circuit. There are all type of breakout boards - but most of them are for different types of sensors, for example: accelerometers, ultrasonic distance sensors, RFID tag sensors, temperature sensors, pressure sensors, and they even have seismic breakout boards for sensing dinosaurs' footsteps! Breakout Board vs Arduino Shield: What's the difference? You might be wondering what the difference is between a breakout board and an Arduino shield, and that is a good question. Breakout boards usually have a smaller form factor - they don't need the entire space of an Arduino shield to accomplish their mission. And while the market for most breakout boards is being driven because of their use with Arduino, since the pin-out of a breakout board is not designed specific to the Arduino headers, it means you could use a breakout board with any other microcontroller development board you want - which gives them a bit more scope than Arduino shields. Also, since breakout boards generally have fewer components than a shield does, you may find the cost is lower than a comparable Arduino shield. As you may have guessed by now, you can find a breakout board that does essentially the same thing as a shield. You might be wondering, if breakout boards are only a few components, why not just buy the integrated circuit the breakout board uses, put it on a solderless breadboard yourself, and then hook them up to your Arduino? That is great question, and there is nothing saying you can't – plenty of people do - especially since the components by themselves are often far cheaper to buy alone from an electronics distributor, like digikey or mouser. So, why the heck are people buying all these breakout boards? It essentially comes down to convenience. Let me list the ways a breakout board can help you out, and then you make the call: Breakout boards can save you space We have already said that breakout boards use integrated circuits. Integrated circuits are kind of like t-shirts - you can get them in all different sizes. Usually breakout boards utilize a tiny version of an integrated circuit called an SMD (surface mounted device). The pins on SMD parts are really small - not something you can easily pop into a breadboard. The larger form factor of an integrated circuit, called a DIP (dual inline package) has bigger pins, which fit easily into a breadboard. The DIP package of an IC will be bigger than the SMD form factor. The point, I am getting to here, is that Breakout boards can sometimes save you space which may or may not be important for your project. Breakout Boards are designed for reuse Another thing about using DIP packages is that while the pins are bigger, they are not necessarily sturdy. If you plan to use a DIP component over and over, the usable life of the pins is only so long - the pins on a breakout board however, are heavy duty and designed for reuse. The DIP version on a component may not be available One other issue you may find is that the DIP version of an integrated circuit is not available - as electronics get smaller over time, the demand for larger components is drying up and manufacturers are moving away from even bothering with the DIP package, which ultimately brings you back to a breakout board. Pin labeling on a Breakout board One great feature of breakout boards is that they usually have the pin names of the integrated circuit labeled on the PCB. This makes hooking up the breakout board to your Arduino a cinch, especially when there are a ton of pins. Otherwise, you are looking at the black box of an IC and referencing the datasheet of the integrated circuit to try to figure out which pin is for what. So now that you know some of the benefits of a breakout board, let's talk about a couple things you might want to consider when you are buying them. Good documentation I said this abo

Apr 14, 20178 min

What is an Arduino Shield?

If you are learning about Arduino, you have no doubt come across the term Arduino Shield. This tutorial will explain what Arduino Shields are, why they are awesome, and several things to consider when buying shields. cool electronics ideas that you have. Now the Arduino in and of itself is pretty amazing - you can do a lot of stuff with an Arduino alone. But when you want to start adding all types of cool technologies like bluetooth, wifi, RF, motor-drivers, etc. it can be pretty tricky; especially if you are new to electronics and programming. Arduino shields take all the complexity of the hardware and reduce it to a simple interface. This allows you to get your idea up and running fast. Now it's not just the hardware that shields take care of, in many cases, Arduino shields also have programming libraries associated with them. These libraries allow you to easily implement the hardware features available on the shield. There are shields for all types of things - LCD shields, LED matrix shields, wifi and bluetooth shields, motor shields, power supply shields, geiger counter shields, there are even shields for cooking hot dogs. Chances are if you need to do something, a shield exists to get you up and running quick. Shields plug right into the top of an Arduino. The black plastic rows of holes along the sides of an Arduino are called headers, and on the bottom of a shield, you have these long spiky pieces of metal, these are called pins. The pins on a shield line up with the header rows on an Arduino and fit snuggly (more on this later). Buying an Arduino Shield? Think about this stuff: Does it have good documentation? Documentation is the fancy way of saying - "will they show me how to use this thing?" Basically, is there some type of tutorial or user manual or forum that talks about how to use the shield. This is one of the biggest factors for me when it comes to buying an Arduino shield. For all the ease of use that a shield provides, if I don't know how to use it, it's about as a good as a rock. Lucky for us, people who use Arduino tend to be awesome and do a great job writing about how to use stuff, so even if the manufacturer doesn't have good instructions, if people actually use the shield, then you will find a wealth of information online. But if you do a web search and it doesn't turn up much of anything useful, you might consider looking for another option. Two US companies that provide superb documentation of the shields they make and sell are Adafruit Industries and Sparkfun. Soldering may be required Many shields are sold as kits, that means they are not fully assembled - and will require you to do some soldering. If you are buying from a reputable source, you should know this ahead of time, but it is worth double checking. Sometimes manufacturers will offer the shield as a kit or fully assembled - I often go for the fully assembled option just to save time. If you have not soldered before, shields are usually a cinch to solder, so don't be intimidated - go get a cheap soldering iron and some solder and go for it! Probably the most important thing when soldering a shield is making sure that the pins on the bottom of the shield are straight up and down, if they aren't they won't line up to the Arduino headers and be a major pain to connect. Stackable or Not Stackable Arduino Shields If you plan on stacking an Arduino shield with other shields, you will want to make sure it is stackable. If it doesn't have pin headers on the top of the shield, or they don't look aligned correctly (usually too narrowly spaced), than it is likely another shield cannot be stacked on top of it. You might also run into a problem if components on the shield stick up too high to allow shields above from getting a snug fit. Manufactures of shields are getting more savvy to this issue, but you should always check. Not all Arduino shields have the same pinout Some older Arduino shields may not have all the pins to fill the header rows of an Arduino. This is because older versions of Arduino didn't have as many pin header slots. This usually isn't too much trouble, unless you needed to use those pins that are not connected on the shield. If you have an older version of Arduino, then a shield you buy might have more pins than your Arduino has headers for - usually they are still physically compatible - this should not be anything to sweat about. Matching Hardware and Software Versions On a final note, if you are having trouble with a shield working, it worth checking to see if you are using the most current library version for your version of shield. A great example is the near ubiquitous Adafruit motor shield. There is a hardware version 1 and a hardware version 2. There are two separate code libraries for these. If you are trying to run your new version of the hardware on the old version of the library - then you will likely run into troubles. It worth checking to see you have the correct library for the job. I hope you fou

Apr 13, 20179 min

How to Use and Understand the Arduino Reference

So you just opened up your fancy new gadget - maybe an awesome DSLR camera, or the newest gaming system, or maybe a new Blu-ray player. As you gladly tear away the packaging - you notice a small book that feels like it was printed on 4th generation recycled newspaper - it's the instruction manual. As you skim the pages you realize it was first written in Japanese, translated to Chinese by an Australian ventriloquist and then an intern in California used Google Translate to finish the job for your native tongue. So you toss the instruction manual and just plug the gadget in. Good for you - especially since it appears as everything is working just fine. Until.. ...something isn't working just fine. Maybe you can't navigate the menu options to find a setting that was advertised on the box, or maybe the functionality you thought your gadget has does not appear to be working no matter how correctly it seems you are pressing the buttons. This tutorial is going to focus on the Arduino instruction manual, known more commonly as the "Arduino Reference" or the "Arduino Documentation". It is an important and useful aspect of learning to use Arduino - it will be your best friend in times of bewilderment, brain lapses and fits of rage. I know that instruction manuals get a bad wrap - but don't fret - the Arduino Reference is awesome! To be honest what really keeps us away from the documentation is our fears. That's right - the reference pages can be a bit intimidating when you are just starting out. They use a lot of technical jargon, are loaded with funky acronyms and filled with rabbit holes. Nobody uses the stuff anyway...right? ( Not right - that was a joke! ) This Tutorial Will Cover: What is the Arduino Reference? The Anatomy of an Arduino Reference Page. Why You Should Be Using the Arduino Reference More. How to use brain waves to trick your cat into eating less. Have you ever read a book and come upon a word you didn't understand? Sometimes you can infer the meaning from it's context, but what about when no such context exists? Likely, you used a search engine to find the definition. The definition told you what the word meant, whether is was a verb or adjective (or both), it gave some examples of how to use the word, and maybe even the etymology. The Arduino Reference is the same thing. It is the "dictionary" for all the structures, variables and functions that you can use when programming a sketch. It tells you the description, the parameters it uses, the syntax (how it is written), and even gives a bunch of examples on how to use it. So let's jump into an Arduino Reference page and dig into what we can learn. The Anatomy of an Arduino Reference Page So let's navigate to a reference page to start our journey. You can find the index of all the Arduino Reference pages on the Arduino Website: http://arduino.cc/en/Reference/HomePage Or - if you are offline - don't worry, your Arduino IDE comes with an html copy of all the pages. You can get to it through the Arduino IDE: Help > Reference You will note at the top of the Reference Index page, there are three columns; Structure, Variables, Functions. This is the first level of organization in the reference. So if you are looking for a variable, you know which column to start looking in. Each of the hyperlinked items on this index page will take you to the individual entries reference page. What's great about the individual reference pages is that they are organized in a similiar manner from one to the next, so you should know what to expect. They are also terse, so don't think you are going to have to scour through someones dissertation. Each page has some major headings. We will walk through each of the main ones, and then talk about some less common ones. Description: All entries will have a description. Pretty straightforward - this is going to be a simple explanation of what the item does. It usually uses language that is basic. Syntax: Most all entries have a "syntax" heading, but they are more prevalent for functions. The syntax shows how the function (or other code) should be written when you use it in your sketch. Basically - it is what the function needs to know to do it's job. Let's take an example from the digitalWrite() reference page. The words in the parentheses are telling you what type of value should be passed to the function. If we want to use this function than it will need to know 2 things - the pin number and the value to write to the pin. You don't type in the word "pin" when you use the function, you would replace that with the actual pin number, or a variable that represents that pin number. Same is true for the word "value", you would replace this with one of the acceptable parameters (see below). So when you actually wrote the function, it might look like this: digitalWrite( 13 , HIGH ) Where 13 is the "pin" and HIGH is the "value". Parameters: Only structures and functions will have the "Parameters" heading. These describe exactly what can

Apr 12, 201712 min

Using Red-Green-Blue (RGB) LEDs with Arduino (Common Cathode Type)

In this tutorial we describe using RGB LEDs of the Common Cathode Type. We will describe setting up the circuit, talk about the LED and discuss the code used to adjust the hue.

Apr 11, 201714 min

Using Random Numbers with Arduino

This video tutorial talks about using the random() and randomSeed() functions with Arduino. It is pretty straight forward, but there are some intricacies worth noting. Creating truly random numbers in Arduino is harder than you might think. The closest we can get in Arduino, and just about anywhere else, is using pseudo random numbers. That is, numbers that mimic randomness, but in fact do have a pattern if Want to fast-track your Arduino skills? Click here to join our 12-part HD Video Course. Why are Random Numbers with Arduino All the Same? The most important thing to understand when using the random() function with Arduino is that it will generate the exact same list of pseudo random numbers every time. So if you build a slot machine, and the first crank of the handle is a winner, then you can be sure that if you reset the Arduino board and pull the handle again - it will still be a winner the first time. The easy way to overcome this is using the randomSeed() function. This function takes a value (an integer for example), and uses the number to alter the random list generated by the random() function. The number you pass to the randomSeed() function is called a 'seed'. You might put randomSeed() in the setup, and then use the random() function in the loop. Something like this: //this variable will hold a random number generated by the random() function long randomNumber; //Set up - this is where you get things "set-up". It will only run once void setup() { //setup serial communications through the USB Serial.begin(9600); //Let's make it more random randomSeed(42); }//close setup void loop() { //generate a random number randomNumber = random(2,5); //display the random number on the serial monitor Serial.print("The Random Number is = "); Serial.println(randomNumber); } But there is still an issue - even though the sequence of random numbers is different when using the randomSeed() function - it will still be the same every time the sketch is run. It is just a different list of pseudo random numbers! One Solution to the Random Problem So, what to do? Lucky for us the Arduino reference has a great solution. Use the analogRead() function to read a value from an unused analog pin. Since an unused pin that has no reference voltage attached to it is basically 'floating', it will return a "noise" value. This noise value can seed the randomSeed() function to produce differing sequences of random numbers every time the sketch is run. Below is the sketch from the video using analogRead() and randomSeed() in unison: /*How to use the random() and randomSeed() function YOU WILL NEED: (3) LEDs (3) 220OHM resistors (1) Jumper Wire (4) Hot cakes CIRCUIT: Connect a resitor to pin 2 and then to a breadboard. Connect the long leg of an LED to the resitor and the short leg to one of the ground rails on the breadboard Repeat this for the other components at pin 3 and 4 Coonect the ground on the breadboard to one of the Arduino GND pins. Created JUL 2014 by Michael James https://programmingelectronics.com/thearduinocourse */ //Declare and initialize LED pin variables int LED_1 = 2; int LED_2 = 3; int LED_3 = 4; //this variable will hold a random number generated by the random() function long randomNumber; //Set up - this is where you get things "set-up". It will only run once void setup() { //setup serial communications through the USB Serial.begin(9600); //Let's print a start messgae to the serial monitor when a new sequence of random numbers starts Serial.println("Starting new Random Number Sequence"); //set the LED pins as outputs pinMode(LED_1, OUTPUT); pinMode(LED_2, OUTPUT); pinMode(LED_3, OUTPUT); //Let's make it more random randomSeed(analogRead(A0)); }//close setup //The loop() runs over and over again void loop() { //generate a random number randomNumber = random(2,5); //display the random number on the serial monitor Serial.print("The Random Number is = "); Serial.println(randomNumber); Well, hopefully that was random enough for you! If you enjoy this tutorial, I highly recommend checking out our free Arduino Crash Course (You can sign up below).

Apr 10, 201713 min

Kit-on-a-Shield for Arduino

Ever ever spent too much time searching for a 220 ohm resistor or just one more jumper wire? Are you sure you had that extra LED, LDR, [Fill in the blank], but have no idea where it went? Do you just want to throw up a quick circuit and get to coding? Travel a lot and want an easy way to learn Arduino on the road?

Apr 9, 20171 min

How to Make One Button Have the Functionality of Two or More with Arduino

Do you have an application where you want multiple buttons for different user inputs? Maybe you have a timer and you want one button for minutes and another for hours. But there is a problem – you only have room for one button! In this tutorial, we are going to use Arduino to explore how to make one button have the functionality of two or more. Click here to join our 12-part HD Video Course. You Will Need: (1) Momentary push button (5) Jumper wires (1) Solderless breadboard (2) LEDs (2) 220 Ohm resistors Set Up The Circuit: To demonstrate making one button have the functionality of two or more, we will set up a simple circuit with 2 LEDs and a button. Based on how we press the button, different LEDs will illuminate. Follow the instructions and schematic below to get the circuit set up before we dive into the mechanics of the Arduino code. Using a jumper wire, connect any GND pin from the Arduino, to the ground rail on your breadboard. Place an LED on your breadboard, make sure to note which way the long leg is facing. Using a jumper wire, connect pin 13 from your Arduino to the breadboard in the same channel where you have the long leg of the LED attached. Now connect one side of the 220 Ohm resistor to the short leg of the LED, and connect the other leg to the ground rail on the breadboard. The orientation of the resistor doesn't matter. Repeat this using pin 12, and another LED and resistor. Finally, place your push button on the breadboard. Depending on the style of your pushbutton, they often fit well straddling the long trench that goes through the breadboard. Connect a jumper wire from one side of the button to pin 2 on the Arduino. Connect a jumper wire from the other side of the button to the ground rail on the breadboard. That's it for the circuit setup. Now, when you press the push button (which will electrically connect both sides of the button), pin 2 to will have ground voltage applied. We will use this ground voltage input to trigger our different functions. Examine the Sketch: There are couple ways to implement the multi-function button press using Arduino. One way is to have the number of presses determine the output. For example, a single click might highlight the "hour" field of an LCD timer and a double click might highlight the "minute" field of the display. Another way that we can implement multiple functions with one button is for the user to hold down the button for different lengths of time with the length of the hold determining the output. For example, if the user holds the button for half a second and releases, something happens. If she holds it for 2 seconds, something different happens. This latter method of using button hold length time to determine separate functions is the strategy we will learn here. Before I go any further though, I would like to thank Steve for creating the base Arduino code that we will be using. Steve is a member of the Premium Arduino course (a couple of months ago, he was new to Arduino). While creating a home automation project, he was in need of using a single button to do multiple things, and came up with a very simple way to make it happen. Thanks Steve! Here is the complete sketch, I recommend looking it over first, and then we will discuss it piece by piece below. /*Using a Single Button, create mutliple options based on how long the button is pressed The circuit: * LED attached from pin 13 to ground through a 220 ohm resistor * LED attached from pin 12 to ground through a 220 ohm resistor * one side of momentary pushbutton attached to pin 2 * other side of momentary pushbutton attached to Ground * Note 1: on most Arduinos there is already an LED on the board attached to pin 13. * Note 2: In this circuit, when the button is pressed, Ground Voltage is what will be applied. Created DEC 2014 by Scuba Steve Modified JAN 2015 by Michael James Both members of https://programmingelectronics.com This code is in the public domain */ /////////Declare and Initialize Variables//////////////////////////// //We need to track how long the momentary pushbutton is held in order to execute different commands //This value will be recorded in seconds float pressLength_milliSeconds = 0; // Define the *minimum* length of time, in milli-seconds, that the button must be pressed for a particular option to occur int optionOne_milliSeconds = 100; int optionTwo_milliSeconds = 2000; //The Pin your button is attached to int buttonPin = 2; //Pin your LEDs are attached to int ledPin_Option_1 = 13; int ledPin_Option_2 = 12; void setup(){ // Initialize the pushbutton pin as an input pullup // Keep in mind, when pin 2 has ground voltage applied, we know the button is being pressed pinMode(buttonPin, INPUT_PULLUP); //set the LEDs pins as outputs pinMode(ledPin_Option_1, OUTPUT); pinMode(ledPin_Option_2, OUTPUT); //Start serial communication - for debugging purposes only Serial.begin(9600); } // close setup void loop() { //Record *roughly* the tenths of seconds the button in being h

Apr 8, 201715 min

Understanding HIGH and LOW Arduino Pin States

If you are just getting started with Arduino, you might be wondering what the heck all this HIGH and LOW stuff everyone is talking about really means. At first I just figured everyone using micro-controllers was just on some type of emotional roller-coaster, until I began to realize that HIGH and LOW are actually abstractions. But let us not talk in abstractions - let us talk in concrete numbers and get down to the bottom of what HIGH and LOW actually mean. This Tutorial Will Include: What the heck is a PIN state? What are the values for Arduino Pin States? Practical Application: What do we see in practice?

Apr 7, 201712 min

Floating Pins, Pull-Up Resistors and Arduino

Floating Pins on Arduino have always been a bit of mystery to me. It just never made much sense. I did this video more for my own sake - just to concrete it in my brain. I hope it can add some solidarity to your understanding as well...

Apr 6, 201710 min

The MOST guaranteed way to NOT buy a Fake Arduino (The Story of Pizza-Duino)

Let's not be duped by people trying to sell us authentic Arduino's that are counterfeit. This video will show you the one way to be sure you get the real deal, and five methods of telling if you bought a counterfeit or not.

Apr 5, 20175 min

Throw out your breadboard! Dr. Duino: An Arduino Shield for debugging and developing Arduino projects

In the last couple of episodes we have talked about Arduino shields and breakout boards. In this video, we will review a specific Arduino shield that makes developing projects and debugging sketches on the Arduino extremely easy - it's called Dr. Duino.Arduino Shield for Arduino Shields The Dr. Duino is an Arduino Shield. As would expect, it fits snuggly on top of the Arduino headers and has pin headers of it's own, which can easily accept a shield on top. The first thing you notice about Dr. Duino is that it's built like a doughnut - it's got a giant hole in the middle! (FYI - It does not taste like said pastry…) There are a couple reasons for this form factor, but foremost is that even after you stack another shield on top of Dr. Duino, you still have easy physical access to all its resources. Dr. Duino Hardware Resources What resources are we talking about? Dr. Duino has 4 momentary pushbuttons, 5 LEDs, 6 potentiometers, an RS232 connector, and a bunch of access points for 5 volts, 3.3 volts and ground, oh yeah, and a siren (piezo buzzer). So how do you access these resources and why would you even care to? Both great questions! The core feature that allows us to use all the hardware I just talked about are groups of three "jumper" pins that surround the board. Almost every pin on the Arduino is associated with a set of these jumper pins. The middle pin is connected directly to the Arduino pin. The pin on the left is connected to the pin header on top of the Dr. Duino. The pin on the right is connected to the one of the hardware resources on the Dr. Duino board. With each set of these three jumper pins we get a plastic encased "jumper" - it fits snug on top 2 pins, and electrically connects them together. For every Arduino pin that has associated Dr. Duino jumper pins we have 2 decisions: 1) We can route the Arduino pin to the shield above by connecting the center pin to the jumper pin on the left. This passes the Arduino pin directly up to the shield if you have one attached, bypassing the Dr. Duino. 2) Or, we can route the Arduino pin to the resource on the Dr. Duino shield, bypassing the shield above. Each pin has a different "resource" or piece of hardware that you can use. Here is a quick mnemonic for remembering how to place the "jumper" on the "jumper pins" – Left goes Up (to the shield above), Right goes to Down (to the Dr. Duino). Digital pins 5, 6, 10, 11, and 13 have LEDs attached. Digital Pins 7, 8, 9 and 12 have momentary pushbuttons attached. Analog pins A0 - A5 have potentiometers attached and digital pin 3 is attached to the piezo buzzer. All these asset are extremely helpful. For example, let's say I am prototyping with a motor shield. What I want is for every time I press a button, then a servo moves 180 degrees. Instead of having to bust out a breadboard and jumper wires, I simply move a jumper on the Dr. Duino and I now have a preinstalled button. As long as the shield is not using that pin for anything, it's fair game to route that pin to the Dr. Duino. Or, maybe I want to turn a potentiometer to get the servo to move. Once again - scrap the breadboard - just move a jumper on one of the analog pins and you have a built in potentiometer - in fact, every analog pin has its own dedicated potentiometer! Trying to put 6 potentiometers on a breadboard and run jumpers is a major pain - having these built right in and so compact is great. Potentiometers are great for simulating sensor inputs too. Say you are developing a project that lights up LEDs based on inputs from a pressure sensor - but you don't have the sensor yet. No worries - just use the potentiometer built in to the Dr. Duino to simulate the input from the pressure sensor. Another great resource is the piezo buzzer. Most of us get used to using the serial window to debug our sketches. For example - we use the Serial .print() function to send a value to the serial monitor window when some threshold is met. What this ends up doing is dividing our visual attention from the Arduino to the computer monitor. With the piezo buzzer, you can get the same information, but be able to look at your Arduino - it allows you to incorporate more of your senses into the debugging process. All of these features add up to a great little development package - it's like a breadboard full of components all connected on a handy shield. So if I am traveling I don't have to pack away a bunch of pieces-parts, I can just throw the Dr. Duino in with my Arduino and go for it. A Tool for Learning Arduino Code Another great use of these resources is when you are learning to use Arduino. If you are really trying to jump right into the code, then setting up the circuit can sometimes be a hassle, even if its just a button and an LED. (Yes - I am that lazy!) With Dr. Duino you can work through practically every sketch in the examples section of the Arduino IDE with only some minor code changes (mostly pin designations changes), without having to add a single piece

Apr 4, 201711 min

Shorthand Arithmetic :: Using Compound Operators (+= , -= , *= , /= ) with Arduino

In this lesson we discuss some common shorthand for simple arithmetic in Arduino. We cover several compound operators that add, subtract, multiply and divide making it easy to increment variables in useful ways.

Apr 3, 201712 min

Understanding Boolean Data Types and Using the Boolean NOT (!) operator to Switch Arduino Pin States

Apr 2, 20178 min

What to do when you just don't know :: Arduino, ADXL345 triple axis accelerometer and an RGB LED

This lesson discusses what to do when you open an existing program and realize that you simply don't understand all the stuff that is going on. It also talks about using the ADXL345 triple axis accelerometer breakout board to control the hue of a Red-Green-Blue (RGB) LED.

Apr 1, 201714 min

3 Ways to Use Acceleration in an Arduino Sketch

This lesson covers three easy ways to implement some form of acceleration in your Arduino sketches. It will cover the following: Linear Acceleration Exponential Acceleration Messing Around with the Square Root function What is Acceleration? Acceleration is the rate of change of something over time. Acceleration would help describe things like: Have fast can a stopped car get to 88mph? If I do a wing-suit jump from the top of Mount Everest, how fast will I be when I am gliding over base camp? How can I gently slow down the movement of a mechanical servo before it comes to rest? We can implement acceleration when programming Arduino quite easily with just a couple lines of code. The basic concept is that a variable will need to change - how it changes over the course of the sketch is what we are interested in. Below are three examples of how we can code change in variables so they display acceleration. Linear acceleration Linear acceleration is a constant rate of change. It can be represented by a sloped line on an x-y axis. A simple way to use it is to increment or decrement a variable every time through a loop like below... for (int i = 0; i You can see in the code above, that each time through the 'for loop', the accel variable is decreasing by 100. If accel started at 1000, this is what accel would look like with respect to the number of iterations of the for loop. You can see that the accel variable decreases at a set rate over time in a linear fashion. Exponential Acceleration Exponential acceleration changes over time too, but it does so more dramatically (It's basically a drama queen). At first the rate of change in the variable is small, but once it begins to increase it really takes off! You can use the power function built into the Arduino IDE to make a variable change exponentially. The power function syntax is quite easy. pow( base, exponent ) The parameter base is the number that get raised to the power of the exponent. Like 2 to the 5th power. Below is an example of how you might code it to change a variable exponentially over the course of a 'for loop'. for (int i = 0; i Looking at a chart of accel over the course of the 'for loop', we can see that the way it changes is much different than linear acceleration: The theme for exponential growth is that is starts out slow, but once it starts going it really get's going! Using the Square Root Function for Acceleration The square root function can also provide some flavor to the output from your Arduino. It's syntax is simple: sqrt( x ) It returns the square root of the number or variable that you put in the parenthesis. Below is an easy way to use it in a 'for loop': for (int i = 0; i Let's look at how accel changes over the course of the for loop(let's say it started at 10,000): You can see the a rapid deceleration in the value of the accel variable of the 'for loop'. Practice With Acceleration: If you want to take a look at what these types of acceleration will do in "real" life, then set up the circuit below. You Will Need: (10) LEDs (10) 220 Ohm Resistors (1) Jumper Wire Arduino Board Bread Board Black Marker Set Up The Circuit: Start by by placing one resistor at pin 2 on your Arduino. Connect the other end of the resistor to the breadboard and then connect the long leg of the LED to the resistor. Place the short leg of the LED in the outer ground rail of the bread board. Then add 9 more resistors and LEDs across - you should stop at Pin 11 on the Arduino. Then add a jumper wire from GND on the Arduino to the shared ground on the breadboard. (All LEDs not pictured). That is pretty much it for the circuit. Below are the code examples for the different ways to program acceleration that we talked about: Here is the code for the linear acceleration: /* Linaer ( Constant ) Acceleration The circuit: * LEDs from pins 2 through 11 to ground created 2006 by David A. Mellis modified 30 Aug 2011 by Tom Igoe Modifeid 21 Jul 2014 by Michael James This example code is in the public domain. http://www.arduino.cc/en/Tutorial/Array */ //Declare and initialize variables // The higher the number, the slower the timing. int timer = 1000; // an array of pin numbers to which LEDs are attached int ledPins[] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; // the number of pins (i.e. the length of the array) int pinCount = 10; void setup() { // the array elements are numbered from 0 to (pinCount - 1). // use a for loop to initialize each pin as an output: for (int thisPin = 0; thisPin Serial Monitor) Serial.print("Back ... LED #"); Serial.print(thisPin); Serial.print(" = "); Serial.println(timer); }//close for //reset timer for next for loop timer = 1000; // loop from the highest pin to the lowest: for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) { // turn the pin on: digitalWrite(ledPins[thisPin], HIGH); delay(timer); // turn the pin off: digitalWrite(ledPins[thisPin], LOW); //decrement timer timer = timer - 100; //let's take a look at the numbers via the serial moni

Mar 31, 201717 min

Check out our premium Arduino Training Course

Mar 30, 20172 min

Understanding the Arduino uber functions loop() and setup()

Discussion: In this lesson, we're going to discuss two very special functions that you will use in every single Arduino sketch that you write. They're called Setup and Loop. Specifically, we'll cover: How Setup Operates and the type of code that it executes How Loop Operates and the type of code that it executes Loop Function's Responsive Outputs How to get those little ships inside the glass bottles I want you to pretend for a moment that you own a specialty Italian sub shop. Business is great, and you have wonderful customers. However, you have one major problem. Employee turnover is very high. This is mostly because the majority of your employees are teenagers who, by nature, tend to move on to different things. It feels like as soon as you get an employee trained, they move on to Harvard Business School or get a scholarship to MIT - or they just decide that bungee jumping all day long is better than making subs. In order to help train new employees, you create two binders of procedure lists. One binder is called "The Morning Setup Binder", and it lists all the stuff that you have to do when you open the store. This binder contains things like unlock the front and back doors, turn on the "Open" sign, put the delivered sausage in the fridge, and get the broccoli out of the fridge. It's stuff that only has to be done once. Once all of that stuff has been done, a new employee can take that binder and stick it on the shelf. Then, they can pull out "The Sub Making Binder". This is the binder that lists step-by-step everything an employee has to do to make a sub and deliver quality customer service. It might go something like this: When a customer walks in, welcome them with a warm, "Hello!" Ask them what type of sub they want. Ask them what type of bread they want. Ask them what type of condiments they want. Ask them if it will be for here or to go. See if they want to add one of Mama's homemade cookies to their order. I think you get the gist. The binder lists these steps in detail and talks about the quantities of toppings for different subs. "The Sub Making Binder" is really the procedure list that drives the task of the employee and will be the binder that the new employee will keep open all day long when they're starting out. They're going to go back to it over and over again for every sub. So, what does this have to do with programming? Well, a program in Arduino has to do similar things like the sub shop. The Setup Function There are certain tasks that need to be done just once when the program first starts. These are things like: setting up a serial communication to talk with the computer over a USB port, setting the modes of microcontroller pins as either inputs or outputs, displaying a welcome message on an attached LCD screen, or possibly turning a servo to a default location. All of these things might only need to happen once when the sketch first starts and never need to be bothered with again until the program is restarted or the Arduino is reset. These are the type of tasks that are put into a special function called Setup. Let's take a look at Setup. First, notice that the color of Setup is different. Unfortunately, the color is reminiscent of baby poop. This automatic coloring, though, is letting you know that the Arduino IDE recognizes the function Setup as a special type of function that's used for controlling the structure of the code. You'll also notice that right after the word Setup there is an opening and closing parenthesis. The Setup function doesn't need any arguments to operate, but you still have to include the opening and closing parentheses just as you would in any other function. To the left is the word void. Void means that the Setup function will not return any data. So this is a function that doesn't need any arguments from us in order to operate and doesn't return any values to us, but it does do something. Its job is to execute all the code inside its opening and closing curly braces precisely one time. Let me say this again - and with a dramatic pause - because it's that important! Setup only runs once. When the program starts up, Setup will run just once. All of the code inside the curly brackets will get executed one time. If you pretend the program is like the high schooler at the sub shop, the first thing she does when she comes to work is open "The Setup Binder" and go line-by-line until everything is done. Once everything in Setup is finished, she closes the binder, and then she goes on to the next binder. The Loop Function For the Arduino sketch, the next binder is the Loop function. The Loop function looks just like the Setup function. It doesn't take any arguments. It has the opening and closing parentheses. It doesn't return any values, so it has that void to the left. Then, it has the opening and closing curly brackets. Just like Setup, when Loop gets executed, the program will work line-by-line down the sketch. However, here's how Loop is different. When the c

Mar 29, 201710 min

Functions: Let's make programming Arduino as easy as possible

Discussion: In this lesson, we're going to do an overview of functions. This will be just a general discussion to lay out a framework for understanding how functions work and how we can use them. More specifically, we'll be talking about: Function Calls Function Parameters Passing Arguments Different Ways Functions Work In an earlier lesson, we said functions are like the verbs of a programming language. If you want to get something done, it's probably going to involve a function. Function Calls The Arduino programming language is essentially the same as C++ and a lot like C. So, it's chock-full of different types of functions that do all kinds of things for us. If you can think of something, there's probably a function that does it. To use this grand variety of functions, all we have to do is type the name of the specific function that we want to use. That's it. You just type its name. Then you follow its name by an opening and closing parenthesis. Sometimes, you have to put values in between those parentheses. Let's take this function called digitalWrite, for example. The digitalWrite function wants to know a pin number on your Arduino, and then it wants to know a state, either HIGH or LOW. Once you give it that information, it will apply either five volts, which would be a HIGH state, or zero volts, which would be a LOW state. When we type digitalWrite in our program, that is called a function call. I want to make sure that you've heard that terminology, function call, because you'll be hearing it quite a bit. We'll actually be going over a lot of terminology in this lesson. Function Parameters Some functions require information from us in order to work properly. The function digitalWrite needed to know two things. It needed to know pin number and high or low voltage. The pieces of information that the function needs to operate are called the function's parameters. You might be wondering, "How am I supposed to know what the parameters of a function are?" That's actually a really good question because when you look at the word digitalWrite, there's nothing in the name that alludes to what parameters it needs. In order to know what the parameters are, you have to look it up in a resource called the reference. The reference is like a user manual for programming languages. For functions that you use all the time, you'll become very familiar with what the parameters are. You won't have to look it up all the time. However, for functions that are unfamiliar, you'll probably have to refer to the reference frequently. It's really easy to use, and you'll learn a lot more about it throughout the course. Passing Arguments Back to our discussion on parameters. As said before, parameters are what a function wants or expects. The actual values that you give to the function, though, are called the arguments. In our digiWrite example, we have the number three and the state as HIGH. Those specific values are the arguments. This might sound like a case of semantics to you, but it's actually quite different. Parameters are just the general definition of what the function expects, like pin number or state. The argument is the specific value that you pass to a function, like 3 or HIGH. One more term to learn is "passing". When I give a function arguments, it's called passing. I pass the arguments to a function. Okay, so let's do a quick recap. When we use a function, it's called a function call because we're calling a function. Seems straightforward, right? The information a function needs to operate are called its parameters. The actual values we send into the function are called arguments. Lastly, when we send those arguments, we say we're passing the arguments to a function. Phew, that's a lot of terminology! Keep in mind that that's all it really is. It's just fancy computer programming words. The reason I want to talk about it here is because we're going to be using these terms throughout the course, and I'm sure you'll hear them elsewhere. Therefore, I think if you understand these terms, it will help us communicate better since we'll all be speaking the same language. Different Ways Functions Work Now let's move on to the different ways that functions work. For some functions, like our example digitalWrite, do something for us. We might pass the number 13 and HIGH to digitalWrite, and digitalWrite then applies five volts at pin 13. The function actually does something physical for us. Other functions just return values. For example, the function digitalRead monitors a pin on the Arduino and lets you know the state of the pin, either HIGH or LOW. It only has one parameter, which is the number of the pin that you want to check. To make sense of this, let's look at this line of code as an example. We have pinState = digitalRead(3). This line of code assigns the output of the digitalRead function to the variable pinState. So when this gets executed, the function digitalRead gets called, and we pass it the value three. Ther

Mar 28, 201711 min

Data Types: One size does not fit all

Discussion: We're going to explore some of the specific data types you'll encounter as you begin to program with Arduino. We'll tackle data types in more detail, to include: Integer and Integer Qualifier Long Float Byte Boolean Character Data Types Recap Let's review what we've learned in previous units. We know that when we create a variable, we need to declare its data type. We also know that a data type is simply a way to classify the types of information that you're going to put in a variable. Data type determines several things: what range of values can be stored in the variable how much space and memory that variable needs what types of operations can be performed on that variable Integer We'll begin our discussion of data types with the most common one that you'll see in this course - the integer. This is abbreviated "int" when you type it into the Arduino IDE. The integer is really the go-to data type if you need to store a number. It can hold a value from -32,768 all the way up to 32,767. Keep in mind that it only holds a whole number. You can't store a decimal, such as 3.14, in a variable whose data type is integer. Also, an integer is a 16-bit value. In other words, it takes 16 bits (or two bytes) of memory to store an integer. It doesn't matter if you put a small number in that integer variable like 10, or a big number like 30,000. The compiler will always set aside two bytes for any integer, regardless of number size. In the grand scheme of things, that's pretty small and is why integers are our friends. They don't take up that much space, even if you need to hold a very large value. Now, what happens if you try to put a number bigger than 32,767 inside an integer variable? Well, it actually rolls over. I'm sure most of you are familiar with Pac-Man. You know how if he goes off the screen, he comes right back on the other side? The same thing happens with variables. Let's say we had an integer variable storing 32,767. Then, we add one to it. The result will actually be -32,768, which is called rolling over. Likewise, if you subtract one from -32,768, the result will be 32,767. This leads us to a really important point. When you create a variable, you should have some idea about how big you expect the stored value will be. That expected value will help you determine what data type you should use for a given variable. Remember, the key aspect of variables is that they change - they can vary. At some point, you'll probably do calculations with those variables and change what is stored there based on your results. You can only put so much water in a bucket before it spills over. Therefore, if the value in that variable at any time exceeds the size allow by its data type, it's going to roll over. You can imagine that might return some really weird results. With this in mind, what happens if you need to store a number bigger than 32,767? Well, you have a couple of options. However, before we abandon the integer for a data type that takes up more of our precious memory storage, let's talk about what signed and unsigned means. Integer Qualifier By default, an integer is signed. This means that it accepts both positive and negative signs. So when we say signed, we're talking about the fact that the value could be negative or positive. What if we know we won't be working with negative numbers? Our variable will never need to store negative values. For example, if I'm using a variable to store the number of days that have passed, there's never going to be a negative number of days. The number is only going to increase from its starting point - unless, for all of you 80's kids out there, I jump in a Delorean or something like that. If this is the case, we can use what is called a qualifier to make an unsigned integer. This gets rid of all the negative values and shifts them into the positive range. To use the unsigned qualifier, all you have to do is write unsigned before the "int" data type and voila... now you can store a value in the range from zero to 65,535 AND you're still only using two bytes of storage. Totally awesome! Rolling over still works the same way, though. If you add one to 65,535, you will roll back to zero. Long That's great, but what if you need a number bigger than 65,535? This brings us to a long. Long is a data type that stores four bytes of data and can hold a value from -2,147,483,648 to 2,147,483,647. You can think of a long as a really big integer. It acts the same way in that it can only hold whole numbers and can be made to qualify as unsigned if needed. This reaps you a whopping range of zero all the way up to four million and some change. Float We still keep running into this whole number wall, though. What if I want to store a decimal value? In programming, a number with a decimal point is called a floating point number. The point can float around the number. The data type for a floating point number is simply the float, and it can hold a value in the range from 340 undecil

Mar 27, 201711 min

Understanding Variables

Discussion: This lesson covers one of the most fundamental of all programming concepts: Variables. This is a really exciting topic because once you have a handle on how variables work, you have one of the biggest keys to understanding how programming works. Specifically, we'll be discussing: Memory Data Types Declaring a Variable Naming Conventions Initializing a Variable What is a variable? Variables are a programming tool that help us store and recall information in our programs. Memory A microcontroller, like the one the Arduino uses, as well as computers in general, have something called memory. Memory is really handy because it allows us to store information for use at a later time. Let's say I'm working on a project that will monitor temperature during the day. I have a temperature sensor that reads the current temperature every 60 minutes from 1 am until midnight. I want the program to record the highest temperature and then display it at the end of the day on an LCD screen. In order for the program to accomplish this, it needs to store two key pieces of information. It needs to store the value of the current temperature, and then it also needs to store the value of the highest temperature that it has encountered thus far. But how do we actually save this information in a sketch? Furthermore, how do we recall it when we need to remember it? In order to do this, we need to use the memory. For now, think of memory as a big wall of lockers, and you can use the lockers to store something. When you need that something again, you just go back to locker and grab it. But how do you remember what locker you put it in? In order for us to do that, we first have to give the locker a name. That name you gave to the "locker", the place where you're storing your stuff, is called a variable. Now technically speaking, a variable is the named address of a specific location of memory. However, I don't want to get caught up in all of the technical stuff. I want to dive into the practical use of variables. Therefore, let's go back to this temperature project. As previously stated, we want to record the highest temperature during a 24 hour period. For our program, I need to store those two key pieces of information: the current temperature and the highest temperature. That means I'll have to name two lockers. I'll call one locker "Current Temperature", and I'll name another locker "Highest Temperature". Let's say my Arduino begins taking the first reading of the day. Maybe the temperature is 50 degrees. So I'll open the "Current Temperature" locker, and I'll put in the number 50. At the same time, I'll also open up the "Highest Temperature" locker. Right now there's nothing in it, but 50 is larger than nothing. Therefore, I'll put the number 50 in the "Highest Temperature" locker, as well. So now both of our lockers have the number 50 in them. After 60 minutes pass, I read the temperature again. Let's say it has raised two degrees to read 52 degrees Fahrenheit outside. I open up my "Current Temperature" locker, and I put in 52. This means that 52 overwrites the number 50 so that now the "Current Temperature" locker has the number 52 in it. I also peek inside the "Highest Temperature" locker. I see that 52 is hotter than 50. I go ahead and replace that also. I'm just going to repeat that process every hour. I open up the "Current Temperature" locker, replace the old value with the new value, and then check to see if I need to replace the temperature in the "Highest Temperature" locker. This reveals the first really important thing about variables and the most powerful thing about variables. The contents of a variable change. The name of the variable stays the same because the variable is just the container for the information. We don't want to confuse it with the actual information itself. The variable is the locker. It's not the actual stuff inside the locker. Let's recap what we've learned thus far. We need to store information, and we use memory to store it. We can think of memory like a wall of lockers. To use one of these lockers, we have to name it, and the name of the locker is called a variable. Once we have it named, we can put stuff in it and refer back to that stuff at a later time whenever we need it again. Again, the name refers to the location of the locker, not the actual content of the locker. Data Types There is another thing we have to do when we make a variable. We also have to say what type of thing we're going to put in it. This is called the Data Type. A good analogy here is to imagine that you have to build a zoo. You have to figure out where each animal is going to go in your zoo, and you have to make sure that each animal is given enough space so it can do its thing. For example, you'll need a bigger cage for a tiger than you will for an African frog display. If you're going to have an aquatic display, you'll need a bigger tank for a shark than you will for a goldfish. Where am I going with this zo

Mar 26, 201711 min

Syntax; the spelling and grammar of programming

You Will Need: The Arduino IDE installed and an Arduino connected to your computer. Discussion: In this lesson, we're going to be talking about programming syntax. We'll be introducing some of the basic programming syntax that you'll be using every time you write a sketch. Specifically, we'll be talking about: what programming syntax is comments the semicolon keywords function syntax layout & indentation Programming Syntax What is programming syntax? I like to use this analogy. You can think of programming syntax like the punctuation and grammar of computer programming. If you've ever read a book, then you're probably really familiar with written punctuation and grammar. For example, in the written word, we use things such as periods, commas, dashes, or semicolons. Languages also have verbs, nouns, diphthongs, and all types of crazy grammar that goes with them. The punctuation and grammar that you're familiar with are tools that help us communicate effectively with one another in the written word. Commas convey a pause. Periods let us know a sentence has ended. Italics and bold text let us know if a word is emphasized. When we're communicating to another person, these are tools that help us do so. Just as written sentences require correct grammar and punctuation to be correct, the same is true for programming languages. However, with programming, in most cases we're communicating with the compiler - the compiler being the program that looks at our code and creates machine language for us. The programming syntax that we use is meant to communicate our intent to the compiler program. For this reason, the programming syntax MUST be correct. You can get away with messing up some grammar and punctuation when you're writing to a friend or an audience. They'll probably understand what your intent is. On the other hand, if you make an error in your programming syntax, there's almost assuredly going to be an issue. You'll have either a compiler error when you go to compile the code or a subtle and hard to find bug in the actual operation of your sketch. When you start out, you'll likely find that getting all the program syntax correct is a major hassle. It just doesn't feel natural, and the compiler is far more exacting than most "red pen crazy" elementary school teachers. The good news is that as you get more comfortable in the programming language, the syntax will come more naturally to you. It will become second nature as you write your code. Comments Let's start with one of the most important tools in programming - the comment. Comments are descriptive statements that a programmer writes to help explain the code. They are syntax and punctuation that really have nothing to do with the compiler. In fact, the whole purpose of a comment is so that you can hide these words from the compiler. There are two ways to create a comment. The first is the single line comment, which uses a double forward slash. It looks like this: Notice that all the text after the double forward slash is grayed out. If you have a lot to say, then you can use a multi-line comment. To start a multi-line comment, you type a forward slash followed by an asterisk. Now you can type multiple lines of comments. You'll notice that they're all grayed out. Also, when you press the enter key after that first line, the Arduino IDE actually auto closes the comment for you. It is closed with an asterisk and another forward slash. These additional asterisks on the lines in between are not required, but they are added by the Arduino IDE. These help the multi-line comment stand out from the rest of the code. As I said, comments are hidden from the compiler. They are words specifically for any other person reading your code - not the computer. I won't go into the substance of comments right now. You'll learn more about what comments should say as you work through the course, but I will say that comments should be descriptive statements explaining what that part of the code will do. Semicolons The next thing I want to talk about is the semicolon. The semicolon is to the C++ programming language as the period is to the English language. A semicolon lets the compiler know that a specific statement of computer code is complete. Let's take this line of code: . I know right now this code means nothing to you, but what I want you to see is the semicolon at the end. This semicolon lets the compiler know that your next line of code is independent from the previous one. If you wanted, you could move the semicolon to the next line of code or even insert spaces. It wouldn't make a difference. However, this is horrible form. You really should keep your semicolon on the same line of code that it ends. I just wanted to point this out to demonstrate that the compiler will ignore the spaces before and after a semicolon. If you forget to type a semicolon and then compile your sketch, you may get several different types of errors. I took out the semicolon from the previous line

Mar 25, 201711 min

Progress vs Perfection: Chicken Analogy

Discussion: Will the Chicken Cross the Road? So there's this chicken, and he's on the side of the road. He wants to cross the road. He wants to get to the other side. Before he steps out and crosses the road, he looks both ways. That is a rational thing to do. If he doesn't look both ways, and he just steps out, he's going to get smashed by a car, and he won't get to the other side of the road. This chicken is a little bit of a nervous chicken. He is just sitting there and watching. A car passes by, another car passes by, and he's looking at each one. He is analyzing the traffic, but he never steps out in the street and actually makes any progress because he's always afraid a car is going to come and nail him. Now, in some regards, you and I are a little bit like that chicken. No, I'm not calling you yellow, or anything like that. That's not where I'm going with this. What I'm saying is that, many times, when we're learning something, especially a step-by-step process, we can get a little caught up on learning it and trying to learn that something to perfection. Instead of actually stepping out into the street and crossing the road, and actually making progress, we're sitting back and kind of studying, and studying, and studying. We're studying that traffic. We're actually not getting anywhere. Stepping out into Uncertainty- At Some Point You Have to Cross the Road In programming electronics, there is a lot to learn. Anytime you start to learn one thing, another thing is going to pop up. It's like this endless amount of rabbit holes. In order for us to actually make progress to our goal, we have to be willing to accept a certain level of uncertainty. We have to be willing to say, okay, you know what, maybe I don't get all of this. But, I am going to take a step forward, and I am to keep moving forward. That is really what I want you to try to think about as you learn all this new information. Some of it might (will) feel a little fuzzy as you move forward, and that is okay! As we go through the course, I'll give you some really good rules of thumb for when I think it's okay for you to take a step forward and say, "You know what? I think that I know this enough." Alright, let's go ahead and get cracking!

Mar 24, 20172 min

The Arduino Development Toolchain - How it all gets done...

Discussion: In this lesson, we're going to do an overview of the Arduino toolchain. The toolchain includes all of the software tools that are between us pressing the Verify/Upload buttons and that code actually getting loaded onto the integrated circuit on the Arduino board. I definitely want to stress the keyword overview because there is a lot going on behind the scenes that actually makes it happen. In practice for us, though, the entire process is just a matter of pressing a button. As we start to dig in, it's tempting to want to know every detail. However, remember that our goal in this course is to learn programming and electronics. If we're not careful, we can get pulled down this huge rabbit hole. That being said, I do think it's important to be familiar with the process. We don't need to understand it in depth. I just want you to be able to understand and recognize some of the terms and basic concepts associated with this toolchain. Specifically, we'll discuss: What Is a Toolchain A Toolchain Analogy Toolchain Basics What in the World Is a Toolchain? So, what is a toolchain in the first place? In programming, a toolchain is just a series of programming tools that work together in order to complete a task. If we were cooking something, like carrot soup, the toolchain might include a carrot peeler, a produce knife, a pot, some water, and a stove. Together, these tools help you create the desired output, carrot soup. When we're developing programs for Arduino, we'll also be using a toolchain. This all happens behind the scenes. On our end, we literally only have to press a button for the code to get to the board, but it wouldn't happen without the toolchain. A Helpful Analogy So, I want to start peeling back the curtain on this Arduino toolchain. Imagine for a moment that you're an author. In fact, you're a New York Times bestselling author... just like me. What type of toolchain might you use? Maybe you start off with text editing software, just like Microsoft Word, to type your awesome story. Once you're done with that manuscript, you send it off to a professional editor at a publishing company. That professional editor is part of this toolchain. He will look over your manuscript and point out any errors. He might do some rearranging and other things, as well. After he sends the suggested edits back to you, you make any necessary corrections. Then, you give the manuscript back to that professional editor to do one last check for errors. He then hands it off to the office next door at that publishing company. The publishing company can't just take that Microsoft Word file and send it off to a printer. They need a special file type to format the book for how it should look on a physical page when it actually gets printed. Therefore, they take the manuscript in a Microsoft Word file format, and they turn it into a new file format. Once this is done, the publisher can send it off to be printed. Luckily, to make the process of printing a whole lot easier, this publisher has an in-house printer. So, he simply needs to just go right down the hall, so to speak. The printer takes that file and prints it onto an actual physical page. So, let's review this author's toolchain. The author writes with a text editor program. Then, he sends the manuscript to an editor at a publishing company. That editor reviews the manuscript until it is perfect. He then sends it next door to be formatted. The manuscript is converted into the proper file format, and it is sent off to the printer to create the physical book. Finally, voilà, somebody buys your book from Amazon to read all about zombies over a warm cup of latte. Arduino Toolchain Basics Why did I go through that long scenario? Well, the Arduino has a similar toolchain. When we start writing our code, and we become the author. We do this in the Arduino IDE, which is akin to a text editor. We also write the code in a programming language called C++, with a file type extension of .ino. The code that we write is called human readable code since it's meant for us to read and, hopefully, understand. However, the Arduino hardware doesn't understand C++ code. It needs what's called machine code. In order to generate that machine code, we use a software tool called a compiler. Remember that Verify button in the Arduino IDE that looks like the checkmark? When you press this button, it compiles the code using compiler software called AVR-GCC. This compiler software does a bunch of stuff. The main thing it does it rearrange some code and check for errors. This is like the professional editor at the publishing company. The compiler also translates the human readable code into machine code. There are some in-between file types and other fuzzy things that go on, but the final output of the compiler is a machine language saved as a .hex file. In order to get this .hex file loaded onto our Arduino's integrated circuit, we need to press the Upload button. This begins another piece of

Mar 23, 20178 min

Arduino Board Hardware overview for people like me

Discussion: This lesson continues our quest of learning more about programming and electronics. In previous lessons, we already discussed several reasons why we have chosen to use an Arduino board as the tool to help us learn. Specifically, we chose the Arduino Uno board. The Uno is the baseline Arduino board, being the one around which other Arduino boards are designed . Therefore, the Uno is a great place for us to start digging in. It's also a fantastic launchpad if you decide to move on to other platforms in the future. In this lesson, we'll do a high-level overview of the Arduino Uno hardware. Specifically, we'll cover: The Concept of an Arduino Board The Three Types of Pin Header Rows: Digital, Analog, and Power Other Miscellaneous Valuable Tidbits The Concept of an Arduino Board As we discuss the hardware, I recommend holding your Arduino board in your hand. Pause the video as needed to take a closer look at the board as we discuss the different components. First, I want to point out that the integrated circuit is the brains behind the Arduino board. It's very likely that the circuit is the Atmel ATmega 328, which is an 8-bit microcontroller. Don't worry about that fancy name. The only thing I want you to understand is that everything on the Arduino board is meant to support that integrated circuit. So, the Arduino exists to make it easy to use this microcontroller. If you look closely at the microcontroller, it may look slightly different from mine, depending on which model you have. It might be really small, called a surface mount component, or it could be a big one like mine, which is called a DIP. Either way, there will be little metal prongs that stick out of the side. These are called pins. These pins are how the microcontroller is able to do stuff. These are used to interface with other hardware and circuitry, such as LEDs, sensors, or even your computer. Therefore, we need to know how to actually connect them to other things. That's where the pin headers come into play. Pin headers, sometimes referred to as just headers, are the plastic rows of holes that stick up from the Arduino board. They are all along the border. Inside of the holes are little metal clips. When you stick a wire down into the hole, that wire will stick and stay there. For example, you can stick the wire that comes out of an LED or a resistor into those holes. The wires are called leads, by the way. The wire makes an electrical contact in that hole. In other words, the wire sticks in the pin header. The metal clamp inside the header clamps onto the wire, and an electrical connection between that wire and a specific pin on the microcontroller is then created. Digital Pin Headers There are three categories of headers: digital, power, and analog. The first one we'll discuss is the digital category. Digital pin headers make up the longest row on the Arduino board. They are numbered from zero to 13. That means there are a total of 14 digital pins that we can use. To make this lesson as practical and easy as possible, for our purposes when I say digital, I mean something that is a discrete state. Let's use color as an analogy. Something that is digital can only be either black or white. Digital does not care about any point of gray in-between. Therefore, digital pins are used in one of two ways. They can be used as inputs to do things like read a voltage. Otherwise, they are used as outputs, such as applying a voltage. When they operate as an input, they can only read two different voltage states - high or low. The same is true when they act as outputs. They can only output two voltage states - five volts (high) or zero volts (low). Just as in anything else in life, there is an exception to this. You'll notice that some of these pins have a little squiggly mark next to them. There should be six of them, located at pins three, five, six, nine, 10, and 11. These specific pins allow you to use a technique called pulse width modulation, or PWM. PWM is a technique that we'll dive into later in the course. It enables us to use digital pins in such a way that they appear as though they are outputting a varying amount of voltage. Again, we'll get into PWM in much greater depth later. Right now I just want to point out those pins, and why they are special. I also want to point out two other pins. Notice that pins zero and one have a "TX" and "RX" next to them with little arrows. That stands for transmit and receive. The Arduino uses these two pins to communicate between the board and the computer. For example, maybe you need to upload your code. Maybe executing your sketch performs serial communication between the Arduino and the computer. Serial communication is another concept we'll be learning later in the course. It's only important that you understand these pins used to transmit and receive. Therefore, it's best to only use pins zero and one as a last resort if you've run out of available pins. The reason for this is that sometimes

Mar 22, 201710 min

Everything you need to know about the Arduino IDE (for now)

Discussion: Now that you have downloaded and set preferences, you need to become familiar with the Arduino Integrated Development Environment, or IDE for short. It works just like a text editor program. I'm only going to cover what I think is important for us to know right now. We do a deeper dive on an as needed basis as we progress through the course. Specifically, in this lesson we'll cover: Selecting an Arduino Board and Serial Port Saving an Arduino File The Editor, Message Area, and Console A Few Other "Good to Know" Items So let's open the Arduino Integrated Development Environment (IDE) and get started. Do this by clicking the Arduino icon. Which Board and Serial Port Should I Use? The first thing we're going to discuss is selecting the correct board. We have to let the Integrated Development Environment know what Arduino board you're using. Go to the "Tools" tab, and then go down to where it says "Board". You'll notice I selected the Arduino Uno since that is what I will use throughout the course. I recommend that you use an Uno or an Uno derivative throughout the course, as well. This will standardize our work in these lessons. Once you've selected the board, next you need to select your serial port. People can sometimes be intimidated by this technical term, but you don't have to be. Serial ports are just the different things connected to your computer. The easiest way to find out which of the ports listed is your Arduino is to first unplug the Arduino from the computer. Go to the ports list under the "Tools" tab, and write down the names of these ports. You only need to write enough to differentiate one from the next - maybe the last word or last few letters. Then, close your Arduino IDE. Plug your Arduino board back in via the USB cable to your computer. Open the Arduino IDE. You should now be able to see an additional serial port not on the list you originally wrote down. That will be the serial port to which your Arduino is connected. For Mac, you'll usually see cu or tty after the "dev/". Those are the common ways Arduino will show up on the serial port for a Mac. For a PC, it shows up as a COM port, but it's hard to know which one it will be. It could be one, two, four, etc. That's why the best method, although primitive, is just to unplug and plug the Arduino back into that port. Once you've chosen the board and port the first time, these settings will stay the same for any subsequent times you reopen the Arduino IDE. The reason I point this out is that if you happen to get a different board at some point, you will have to remember to change the board that is selected. The Arduino File When you open the Arduino IDE for the first time, it will open up a file for you, giving it a default name. That default is sketch, underscore, and the current date. That name also appears at the top of the IDE, along with the version of Arduino you're using. To save this, go to the "File" tab and then to "Save". It's just like saving any other file. Notice it asks you to save the file in "Documents". Remember that in Arduino, files are referred to as sketches. So, the collection of our sketches is known as the sketchbook. The sketchbook folder is where all of the sketches we write will be saved. Of course, you can also nest your files in that folder just like you could in any other program where you're saving files. It's really no different. Take a look at the name I chose for my file. There are certain rules you must follow when choosing a name for your sketch. When you're naming a file, you can't use any spaces between the words. One common method is to use an underscore where you would have normally preferred a space. You can't use special characters, either. You can use numbers in the name, but you can't have a number as the first character. Lastly, the names are limited to 64 characters. So, using these rules, name your sketch and save it. You'll see that the name on the tab and at the top of the screen now displays the name of your newly saved sketch. So, saving is really easy. The shortcut command is Ctrl S. There is also a down arrow that you can click. The Editor, Message Area, and Console There are three main areas of the Integrated Development Environment: the editor, the message bar, and the console. The editor is the big white space. It's where you type the Arduino code. It has number lines down the side - as long as that was one of the preferences you checked from our last lesson on choosing your settings. Right now it shows one through nine. If we were to add more code or move our cursor down further, it would adds numbers as lines are added. I want to point out one thing in this name here. Do you see the little funky looking "s"? Every time you make a change to the sketch that has not been saved, that s will be displayed. If I save the file, it goes away. If I were to type something in the sketch again, the funky little s would come back. It's just a visual reminder to save your changes. Per

Mar 21, 201711 min

Mac - Download and Install the Arduino IDE

Discussion: Before you begin using the Arduino IDE, you must first learn how to download, install, and set your preferences. This lesson is specifically tailored for those who use a Mac. (The last lesson covered this same topic, but for PC users.) I'm currently running Mac OS X Yosemite. You are probably running a newer version of Windows. However, the following instructions will be almost identical from one version to the next. If this should ever change, I'll update this lesson to reflect those changes. Find the Arduino IDE Download First, jump on the internet with your favorite browser, and navigate to www.arduino.cc. Look for the tab labeled "Download". The page on which you land might look a little different than this. It does change from time to time, but there will always be an obvious tab for Download. Go ahead and click Download. We're currently working on version 1.6.5, and what you'll do is select your operating system. Click on that "Downloads tab". That will bring you to the "Download the Arduino Software" page. Once on this page, choose your operating system. For Mac users, you have two options. You can download from the green panel: Or you can get the absolute latest, razor-sharp release of the Arduino IDE. This is found in the section labeled "Hourly Builds". If you want the most recent update, you can download from this section. But this is just as the name implies. The information here can be updated as often as hourly, and may not be as stable as an official public release. Therefore, in this lesson, I will demonstrate the Windows Installer. This is the best route to go in almost any case. It's rare that another option is better. Download and Install I'm using Mac OS X. Therefore, I'll click that. It then prompts me to save a Zip file. It doesn't matter where you save this Zip file. I'm going to save it to my Downloads folder. I'm going to save it to my downloads folder. This will initiate the download. It's not a big file. It's around 131 Megabytes for this current release. I have just an everyday, run of the mill cable internet connection, and yet it still doesn't take very long to download. Once it's completely downloaded, I'm going to find it using "Finder". It found it in my Downloads folder. Double-click your Zip file. The Archive Utility for Mac will automatically unzip it for you. After the Zip file has been unzipped, you'll see that the Arduino IDE icon will be created inside whatever folder you unzipped the Zip file. (I'm just trying to see how many times I can say "Zip".) I'm going to move the Arduino program to the Applications folder on my Macintosh computer. So go to the Macintosh hard drive, then Applications, and then drop it in there. Now, I already have Arduino installed. If you already have an older version of Arduino installed, it will ask if you want to first uninstall the older version before continuing the download of the newer version. My recommendation is to select "Replace" to uninstall the older version. It will not harm anything or delete any work you have done. It simply gets rid of the older Arduino IDE, not your sketch folder. If you don't know what that means, it's not important. Just know that you will not lose anything if you uninstall. Next, it will run through the uninstallation process. Once completed, you can see that the Arduino icon is in the Applications folder on my Mac. Right-click on this and choose to open it. It's going to give me a prompt the first time I open up the Arduino IDE. It double check whether or not you really want to open it since it is from an unidentified developer. Just click "Open". By the way, if you try to open the Arduino icon from the Applications folder in your dock, you may not even get an "Open" option. In this case, locate the Arduino icon in the Finder and right click to open. Set Preferences for Arduino IDE Now that the Arduino IDE is open, maximize it. In another video, we'll discuss how this works in-depth, but for now I just want to set some preferences. Go up to Arduino, then click "Preferences". Probably the most important thing to look at is the first line that comes up - the Sketchbook location. When we write a program in the Arduino IDE, it's called a sketch. All sketches are saved within a Sketchbook. The Sketchbook is a folder where you can to keep all of your work. The default location is usually under Users\The User's Name\Documents\ and then a folder created that is named Arduino. If yours does not look like this, or if you would prefer the Sketchbook folder be in a different place, you can browse to select a different location. I would definitely recommend using a folder named Arduino. This default location has always worked pretty well for me. The next preference to set is the Editor language. You can pick from a bunch of different languages. I'm using English, obviously. Another setting is editor font size. The default is 12, but I prefer a larger font. Font size 18 works very well for me. Be aware th

Mar 20, 20177 min

PC - Download and Install the Arduino IDE

Discussion: Before you begin using the Arduino IDE, you must first learn how to download, install, and set your preferences. This lesson is specifically tailored for those who use a PC. The next lesson will cover this same topic, but for Mac users. I'm currently using a Windows 8.1. You are probably running a newer version of Windows. However, the following instructions will be almost identical from one version to the next. If this should ever change, I'll update this lesson to reflect those changes. Find the Arduino IDE Download First, jump on the internet with your favorite browser, and navigate to www.arduino.cc. Look for the tab labeled "Download". The page on which you land might look a little different than this. It does change from time to time, but there will always be an obvious tab for Download. Click on that "Downloads tab". That will bring you to the "Download the Arduino Software" page. Once on this page, you have several options. You can download the Windows Installer, or you can download a Windows ZIP file if you are a non-administrator. The third option is to get the absolute latest, razor-sharp release of the Arduino IDE. This is found in the section labeled "Hourly Builds". If you want the most recent update, you can download from this section. But this is just as the name implies. The information here can be updated as often as hourly, and may not be as stable as an official public release. Therefore, in this lesson, I will demonstrate the Windows Installer. This is the best route to go in almost any case. It's rare that another option is better. Download and Install When you click on the "Windows Installer" link, it takes you to a contributions page. It's completely up to you if you want to contribute to the Arduino cause. It is a great idea if you do. However, since this is simply a demonstration, I'm just going to choose download. Next, a popup window opens so that you can direct where to save the ZIP file. It really doesn't matter where you save it. I'm going to save it to my downloads folder. It will then immediately start to download. It's not a big file. It's around 77.7 Megabytes for this current release. I have just an everyday, run of the mill cable internet connection, and yet it still doesn't take very long to download. Once the file is done downloading, double click the executable file. This will open a couple of popup windows. The first one is dependent upon whether or not you already have a older version of Arduino installed. If you already have an older version of Arduino installed, it will ask if you want to first uninstall the older version before continuing the download of the newer version. My recommendation is to select "Ok" to uninstall the older version. It will not harm anything or delete any work you have done. It simply gets rid of the older Arduino IDE, not your sketch folder. If you don't know what that means, it's not important. Just know that you will not lose anything if you uninstall. Next, it will run through the uninstallation process. Once completed, click "Ok". Then, close the uninstall box. Afterwards, agree to the new license, which is just like any other license that basically says you owe Arduino your children. The popup window then asks you to set a few installation options. Just leave all these checked. Finally, you select the install location. I personally put it into my programs folder. Once you click "Install", it will start extracting. That's really it for the installation. It does take a little longer than you might expect - maybe a minute or two to install the whole package. Set Preferences for Arduino IDE Once installed, open the Arduino IDE. You can either use the desktop icon or go to your programs folder to use the icon there. We're going to set some Preferences. Go to "File" and then "Preferences". Probably the most important thing to look at is the first line that comes up - the Sketchbook location. When we write a program in the Arduino IDE, it's called a sketch. All sketches are saved within a Sketchbook. The Sketchbook is a folder where you can to keep all of your work. The default location is usually under Users\The User's Name\Documents\ and then a folder created that is named Arduino. If yours does not look like this, or if you would prefer the Sketchbook folder be in a different place, you can browse to select a different location. I would definitely recommend using a folder named Arduino. This default location has always worked pretty well for me. The next preference to set is the editor language. You can pick from a bunch of different languages. I'm using English, obviously. Another setting is editor font size. The default is 12, but I prefer a larger font. Font size 18 works very well for me. Be aware that sometimes if you make the font too big, you'll see that one line actually gets written over top of the other. Therefore, you might have to play around with font to find your optimal size. There are a few other things that I

Mar 19, 20177 min

Arduino Integrated Development Environment Version

Discussion: The following videos will show you step by step how to download and install the Arduino Integrated Development Environment, or IDE for short. We'll also be setting up some preferences in the IDE. The phrase Integrated Development Environment may sound complicated and crazy, but it's really not. To be perfectly honest, it looks and feels a lot like a text editor, such as Microsoft Word or Notepad. Arduino IDE is simply a small software program that we're going to load on our computer. It's where we'll write the code that actually gets loaded onto the Arduino board. Consistent Look and Feel It is completely free to download and use. Understand, though, that it's updated all the time. Being kept updated is a good thing. You just need to make sure you are aware of which version you are using. Usually the updates are fairly minor and only affect the appearance of the IDE. Maybe the some of the menu options will be reorganized, or maybe some keyword coloring will change. However, generally speaking, the IDE maintains a consistent look and feel from one version to the next. I really can't stress enough that it doesn't matter which version of the Arduino IDE you're using while you follow along in the course. The Version for This Course For this course and all of the videos, I used Version 1.6.6. Depending on when you take the course, there may be a newer version of the Arduino IDE available. Maybe some of you already have a different version installed. As I said before, the lion's share of the changes from one version to the next are very trivial. The computer code and concepts taught in this course, though, always stay the same. Now, I understand if you want to get the exact same version that we use in the course. This will ensure that everything you see in the videos is a mirror image of what you'll see in your Arduino IDE software. To do this, just make sure you click on Version 1.6.6 when you install. This and all past versions of the Arduino IDE are kept on the Arduino website. We'll discuss this further as we walk through the next few lessons. I can't wait to get you up and running!

Mar 18, 20172 min

Map of the Familiarization Module

Discussion: Before we can start diving into programming the microcontroller on the Arduino, we need to have a solid understanding of the tools used to make it happen. Therefore, in this particular lesson, we're just going to do an overview of what you'll learn in this familiarization module. As the name implies, this module will get you familiar with the software and hardware tools used throughout this course and beyond. More specifically, this section will cover: The Arduino IDE Version Used in This Course How to Download, Install, and Set Preferences The Arduino IDE Itself The Arduino Board The Arduino Toolchain First, however, I want to explain how best to learn the objectives of this and any other module. There are several things provided in each lesson that can help you be more successful as you move through the course. Obviously, you need to become familiar with the Arduino software and hardware. In addition to this, each lesson has accompanying videos, challenges, and further reading suggestions. Take advantage of these, and you'll easily rock this course! Get to Know Arduino Integrated Development Environment (IDE) In the beginning of this module, we'll discuss administrative items regarding the version of the Arduino IDE used here. Then, I'll walk you step-by-step through downloading and installing the Arduino IDE. We'll also talk about setting up some of the preferences. Once we have it installed, then we'll get familiar with the Arduino IDE itself - some of the buttons, tabs, and that type of thing. Afterwards, we'll take a close look at the Arduino board hardware. Finally, we'll do an overview of the Arduino toolchain. Even if you already have the Arduino IDE installed, and even if you have already been creating programs with it, I still say it's a great idea to watch the videos in this section. There might be a couple of things that can help expand your knowledge of the IDE and the hardware - maybe even some tricks or tips that you've not seen before. Doing the Challenges is the Key to Growth Check out the challenges at the end of each lesson. This lesson will not have challenges since it is just an introduction to the module. However, most lessons will have programming challenges after the lesson discussion. These will help cement in your mind the concepts taught in that lesson, as well as offer more ways for you to practice your newly acquired skills. Practice and repetition will help your grow your knowledge base. By diligently doing the challenges, you'll get some real programming and electronics experience under your belt. Also, pay close attention to the further reading section. It will contain links that will point out other tutorials and helpful online resources online. Of course, don't feel like you have to read every linked article. If there's a resource that I feel is exceptionally helpful, I'll make sure to make a note of it in the further reading section. Enjoy this module!

Mar 17, 20172 min

Parts List

Discussion: In this video, I'll explain what parts you'll need to complete this Arduino Crash Course. Immediately below this discussion section, there is a summary checklist of links for these parts. You're welcome to check it out! The links take you to Jameco, a United States based electronics supplier. I'm actually one of their affiliates. So, if you decide to click any of those links below, you'll be helping to make me a multi-millionaire and continue to buy fuel for my yacht. So that would be awesome. All joking aside, you might already have a lot of this stuff laying around. It just depends on how much you've been into electronics thus far. The first thing you'll need is an Arduino UNO. As you may or may not know, Arduino has all types of derivatives out there. An Arduino UNO There is a company named Arduino that made the board. That is the official Arduino, but Arduino is open-source hardware. In other words, the Arduino company made the board's schematics and everything publicly available. Therefore, anybody can take access that information and replicate the board. Anyone can duplicate it, modify it, and even legally sell it. That's why there are so many derivatives, or clones, out there of an Arduino UNO board. They are basically the exact same thing as your official Arduino UNO. Sometimes you'll find that maybe one or two customizations have been made. My recommendation to you is to get an authentic, official Arduino UNO from the Arduino company while working through this course. The reason is because that prevents any discrepancies and concerns about hardware when following the tutorials. If you're following everything in the lesson, and something is amiss, then you can at least know it's not the hardware. You'll know that you have the same hardware with which I'm working. Again... that's just my recommendation. Now, if you already have an Arduino clone or derivative, feel free to use it. It will probably work just fine. The next thing you'll need is a USB cable to plug your Arduino into your computer. Basic procedure is to write code on the computer and then transfer that code, uploading it to the Arduino board. An AB USB cord The USB we'll be using in this course is an A-B type. One end looks like your typical USB that just plugs into a computer, and the other end is almost square - or maybe more like a little house, depending on your imagination. This other end is what would typically go into the back of a printer. You will also need light-emitting diodes, or LEDs. An LED It's best to get at least 10 of the five millimeter type. Any color of mix of colors is fine. I usually use red or white. Next on the list are resistors. Resistors Resistors, as the name suggests, resist the flow of current in a circuit. The bigger the number of the resistor, the more current they resist. When it resists current, the resistor takes that electrical energy and transforms it into heat energy. Therefore, it's important to note resistors can get hot. Just file that away as a quick mental note for later down the line when we begin setting up circuits. You may not notice it that much for the lower level things we will be doing. However, I wanted to make you aware just in case. This is the list of required resistors: ten 220 Ohm resistors and two 10,000 Ohm resistors (also referred to as 10 K resistors). You'll also need a potentiometer. Potentiometers It really doesn't matter what size you get. I'll be using a 10 K potentiometer for this course. If you have one around, you can just use that. A potentiometer is similar to a resistor, but it's resistance can vary. That allows you to create something called a voltage divider. We won't get into that now. Just know that you need a potentiometer of any size. Next, you'll use a solderless breadboard. No, we won't be cutting bread - although food does sound really good right now…. But I digress, a solderless breadboard is a circuit board where you can connect electrical components together without having to solder them. It has a bunch of little holes in it, and in the holes are all these little copper clips. A solderless breadboard The holes are aligned in a bunch of rows and columns. The columns are electrically connected, but the rows are not. So, you stick the leads of your electrical components, such as an LED, into the holes for the metal clips. This will complete the circuit, connecting the electronics. This is an example of how you'll use the breadboard. Don't worry, it's a lot easier than it sounds. For prototyping, like we'll be doing, it's a great tool since it permits quick and easy setup and changes to your circuit. The next required items are jumper wires. Jumper wires These fit down into the little holes on a breadboard and into the little holes on the Arduino board. (We'll be talking about the Arduino board more later, but those are called the headers.) Anyway, the jumper wires allow you to extend your electrical connections, giving you some extra space with w

Mar 16, 20177 min

Rebranding Clarification

Open Source Hardware Group is now Programming Electronics Academy - we rebranded!

Mar 15, 20171 min

Our Premium Arduino Training

Check out our Premium Arduino Training Course.

Mar 14, 20172 min

If Statement Conditionals

If Statement (and else-if), Comparison Operators and Conditions In the last lesson, we learned about the if statement. The if statement was the perfect choice for setting up instructions to run only when certain conditions were met. "If 30 seconds has passed – stop the heating element" or "If the sensor perceives a wall – turn 180 Degrees". This lesson will expand on this amazingly useful function and show you how to stack different conditions to satisfy the flexibility you want in your designs. If you like this tutorial, click here to check out FREE Video Arduino course – thousands of people have really enjoyed it. You Will Need Potentiometer (doesn't matter what resistance range) 220 Ohm Resistor LED (any color) Jumper Wires (3) Alligator Clip Dull machete with wood handle Step-by-Step Instructions Place the potentiometer in the breadboard. Place a jumper wire from one of the outside leads of the potentiometer to the 5V pin on Arduino. Place a jumper wire from the other outside lead of the potentiometer to one of the GND pins. Place the final jumper wire from the center pin of the potentiometer to the A0 pin. Connect either side of the 220 ohm resistor to pin 13. Connect the short leg of the LED to GND (the GND pin next to pin 13 is the most convenient). Attach the other leg of the resistor to the long leg of the LED. Plug your Arduino into your computer with the USB cable. Open the Arduino IDE. Open the sketch for this section. Click the Verify button (top left). The button will turn orange and then blue once finished. Click the Upload button. The button will turn orange and then blue when finished. Open up the Serial Monitor window. Tools > Serial Monitor. Adjust the potentiometer and watch as the LED turns on and off based on the knob position. If Then Statement Conditionals Set up This image built with Fritzing. /* Conditionals - If statement This example demonstrates the use of if() statements. It reads the state of a potentiometer (an analog input) and turns on an LED only if the potentiometer goes above a certain threshold level. It prints the analog value regardless of the level. The circuit: * potentiometer connected to analog pin 0. Center pin of the potentiometer goes to the analog pin. side pins of the potentiometer go to +5V and ground * LED connected from digital pin 13 to ground * Note: On most Arduino boards, there is already an LED on the board connected to pin 13, so you don't need any extra components for this example. created 17 Jan 2009 modified 9 Apr 2012 by Tom Igoe This example code is in the public domain. http://www.arduino.cc/en/Tutorial/IfStatement */ // These constants won't change: const int analogPin = A0; // pin that the sensor is attached to const int ledPin = 13; // pin that the LED is attached to const int threshold = 400; // an arbitrary threshold level that's in the range of the analog input void setup() { // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); // initialize serial communications: Serial.begin(9600); } void loop() { // read the value of the potentiometer: int analogValue = analogRead(analogPin); // if the analog value is high enough, turn on the LED: if (analogValue > threshold) { digitalWrite(ledPin, HIGH); } else { digitalWrite(ledPin, LOW); } // print the analog value: Serial.println(analogValue); delay(1); // delay in between reads for stability } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 /* Conditionals - If statement This example demonstrates the use of if() statements. It reads the state of a potentiometer (an analog input) and turns on an LED only if the potentiometer goes above a certain threshold level. It prints the analog value regardless of the level. The circuit: * potentiometer connected to analog pin 0. Center pin of the potentiometer goes to the analog pin. side pins of the potentiometer go to +5V and ground * LED connected from digital pin 13 to ground * Note: On most Arduino boards, there is already an LED on the board connected to pin 13, so you don't need any extra components for this example. created 17 Jan 2009 modified 9 Apr 2012 by Tom Igoe This example code is in the public domain. http://www.arduino.cc/en/Tutorial/IfStatement */ // These constants won't change: const int analogPin = A0; // pin that the sensor is attached to const int ledPin = 13; // pin that the LED is attached to const int threshold = 400; // an arbitrary threshold level that's in the range of the analog input void setup() { // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); // initialize serial communications: Serial.begin(9600); } void loop() { // read the value of the potentiometer: int analogValue = analogRead(analogPin); // if the analog value is high enough, turn on the LED: if (analogValue > threshold) { digitalWrite(ledPin, HIGH); } else { digitalWrite(ledPin, LOW); } // print the analog value: Serial.println(analogVal

Mar 13, 201714 min

Fade an LED with Arduino

Let's expand the repertoire of output that we can use by looking at the function analogWrite(). I experienced much confusion with analogWrite(), because I suspected that it had to do with the analog pins on the Arduino. The function, however, has nothing to do with the analog pins. There are 5 pins on most Arduino boards marked with 'PWM' next to the pin number (on some boards it is an "~" symbol) – these pins can be invoked to rapidly change the power being applied at the pin – this is a technique called pulse width modulation (PWM). If you like this tutorial, click here to check out FREE Video Arduino course – thousands of people have really enjoyed it. You Will Need LED – any color is fine 220 Ohm Resistor Alligator Clip Glacial ice cubes Step-by-Step Instructions Take the short leg of the LED and insert it in the GND pin. Take either leg of the resistor and place it in pin 9. Connect the long leg of the LED with the other leg of the resistor using an alligator clip Plug the Arduino into your computer with the USB cable Open up the Arduino IDE Open the sketch for this section. Click the Verify button (top left). The button will turn orange and then blue once finished. Click the Upload button. The button will turn orange and then blue when finished. Watch in mesmerizing amazement as the LED fades in and out. Arduino Fade an LED BoardThis image built with Fritzing. Discuss the Sketch Below is the sketch in its entirety from the Arduino IDE: /* Fade This example shows how to fade an LED on pin 9 using the analogWrite() function. This example code is in the public domain. */ int led = 9; // the pin that the LED is attached to int brightness = 0; // how bright the LED is int fadeAmount = 5; // how many points to fade the LED by // the setup routine runs once when you press reset: void setup() { // declare pin 9 to be an output: pinMode(led, OUTPUT); } // the loop routine runs over and over again forever: void loop() { // set the brightness of pin 9: analogWrite(led, brightness); // change the brightness for next time through the loop: brightness = brightness + fadeAmount; // reverse the direction of the fading at the ends of the fade: if (brightness == 0 || brightness == 255) { fadeAmount = -fadeAmount ; } // wait for 30 milliseconds to see the dimming effect delay(30); } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 /* Fade This example shows how to fade an LED on pin 9 using the analogWrite() function. This example code is in the public domain. */ int led = 9; // the pin that the LED is attached to int brightness = 0; // how bright the LED is int fadeAmount = 5; // how many points to fade the LED by // the setup routine runs once when you press reset: void setup() { // declare pin 9 to be an output: pinMode(led, OUTPUT); } // the loop routine runs over and over again forever: void loop() { // set the brightness of pin 9: analogWrite(led, brightness); // change the brightness for next time through the loop: brightness = brightness + fadeAmount; // reverse the direction of the fading at the ends of the fade: if (brightness == 0 || brightness == 255) { fadeAmount = -fadeAmount ; } // wait for 30 milliseconds to see the dimming effect delay(30); } The sketch starts with the usual multiline comment describing the program and how to set up the circuit. The first block of code we encounter is the declaration and initialization of three integer variables. The variable names and comments are both descriptive and helpful – remember this when naming and commenting your own code – useful comments are a pillar of success! int led = 9; // the pin that the LED is attached to int brightness = 0; // how bright the LED is int fadeAmount = 5; // how many points to fade the LED by 1 2 3 4 5 int led = 9; // the pin that the LED is attached to int brightness = 0; // how bright the LED is int fadeAmount = 5; // how many points to fade the LED by The brightness variable will store the value of the current brightness of the LED. fadeAmount is the rate at which the LED will fade and brighten. And of course, as the comments explain, led is simply the pin number where we have attached the LED (through a 220-ohm resistor). Now that we have declared and initialized our variables, we move on to setting up the board with the setup() function… void setup() { // declare pin 9 to be an output: pinMode(led, OUTPUT); } 1 2 3 4 5 6 7 void setup() { // declare pin 9 to be an output: pinMode(led, OUTPUT); } The only thing we do here is set the mode of pin 9 as an OUTPUT using the pinMode() function. Recall that pinMode() takes two arguments – the pin number and the mode. In this case, we assign the pin number using the variable led, which we previously initialized as the number 9. By now you know that setup() only runs once – the code inside the setup() curly bracket will only be executed a single time by the Arduino. Where the real action happens is in loop(). The first function we encounter in the

Mar 13, 201720 min

How to read voltages with analogRead()

In the last lesson you learned about using the analogRead() function to collect data from a sensor connected to one of the Arduino analog pins. The range of data we received from the analogRead() function was mapped between 0 to 1023. What if we want to know the actual voltage being applied at the pin? If you like this tutorial, click here to check out FREE Video Arduino course – thousands of people have really enjoyed it. You Will Need Potentiometer (any resistance range will work) Jumper Wires – at least 3 Persian Rug Step-by-Step Instructions Place the potentiometer into your breadboard. Run a jumper wire from the 5-Volt pin of the Arduino to either one of the outside pins of the potentiometer. Run another jumper wire from one of the ground pins on the Arduino (labeled GND) to the other outside pin of the potentiometer. Run the final jumper wire from pin A0 on the Arduino to the middle pin of the potentiometer. Plug the Arduino into your computer. Open up the Arduino IDE. Open the sketch for this section. Click the Verify button on the top left side of the screen. It will turn orange and then back to blue once it has finished. Click the Upload button (next to the Verify button). It will turn orange and then back to blue once it has finished. On the menu bar, go to Tools > Serial Monitor – this will open the Serial Monitor window – you should see numbers rolling down this screen. Now adjust the knob of your potentiometer and watch the serial monitor window, the numbers should adjust between 0 and 5. Adruino Board Set up For Switch Case This image crafted with Fritzing. The Arduino Code /* ReadAnalogVoltage Reads an analog input on pin 0, converts it to voltage, and prints the result to the serial monitor. Graphical representation is available using serial plotter (Tools > Serial Plotter menu) Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground. This example code is in the public domain. */ // the setup routine runs once when you press reset: void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); } // the loop routine runs over and over again forever: void loop() { // read the input on analog pin 0: int sensorValue = analogRead(A0); // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V): float voltage = sensorValue * (5.0 / 1023.0); // print out the value you read: Serial.println(voltage); } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 /* ReadAnalogVoltage Reads an analog input on pin 0, converts it to voltage, and prints the result to the serial monitor. Graphical representation is available using serial plotter (Tools > Serial Plotter menu) Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground. This example code is in the public domain. */ // the setup routine runs once when you press reset: void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); } // the loop routine runs over and over again forever: void loop() { // read the input on analog pin 0: int sensorValue = analogRead(A0); // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V): float voltage = sensorValue * (5.0 / 1023.0); // print out the value you read: Serial.println(voltage); } Discuss the Sketch This sketch does the exact same thing as the last lesson sketch except for one important change. It takes the reading provided by the analogRead() function and converts it into the actual voltage value at the respective analog pin. Let's start from the top to review what is taking place. We have no variables to declare and initialize at the beginning of the sketch so we jump right into the setup() function. Inside the curly braces of setup() we begin serial communications by setting the baud rate. This is done using the function Serial.begin(9600). void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); } 1 2 3 4 5 6 7 void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); } That is all there is to the setup() of this sketch. The next block of code is loop(). Inside the curly braces of loop() the first thing we do is read the value at analog pin A0 and assign it to an integer variable called sensorValue. int sensorValue = analogRead(A0); 1 int sensorValue = analogRead(A0); Once we have recorded this value, we want to convert it to an actual voltage. You will recall that the range returned by the analogRead() function is between 0 and 1023. We want this to reflect the actual voltage at the pin – which is between 0 and 5 volts depending on where the potentiometer knob is turned. So let's take a look at how we might accomplish this… Explanation of analog sensor code float voltage = sensorValue * (5.0 / 1023.0); 1 float voltage = sensorValue * (5.0 / 1023.0); The first thing we encounter is a new data type – called float. A float is simply a number with a de

Mar 12, 201714 min

analogRead() and the Serial Port

Knowing if something is on or off can be extremely useful, but often you will want to know more. How bright is the light? How fast is the satellite moving? These types of answers are often analog – they cover a large range of values, not just on or off. The Arduino handles analog inputs with 6 dedicated pins, labeled A0 through A5. These pins have access to an analog-to-digital converter, which takes the range of input values and creates a digital version by cutting up the range into tiny pieces. All this is handled behind the scenes – all you have to do is use some very simple functions and you will get what you need. You Will Need Potentiometer (any resistance range will work) Jumper Wires – at least 3 Bicycle tire Step-by-Step Instructions Place the potentiometer into your breadboard. Run a jumper wire from the 5-Volt pin of the Arduino to either one of the outside pins of your potentiometer. Run another jumper wire from one of the ground pins on your Arduino (labeled GND) to the other outside pin of the potentiometer. Run the final jumper wire from pin A0 on your Arduino to the middle pin of the potentiometer. Plug the Arduino into your computer. Open up the Arduino IDE. Open the sketch for this section. Click the Verify button on the top left side of the screen. It will turn orange and then back to blue once it has finished. Click the Upload button (next to the Verify button). It will turn orange and then back to blue once it has finished. On the menu bar, go to Tools > Serial Monitor – this will open the Serial Monitor window – you should see numbers rolling down this screen. Now adjust the knob of the potentiometer and watch the serial monitor window. The numbers should adjust between 0 and 1023. Using the Arduino analogread and map function with a potentiometer at pin A0 This image composed with Fritzing. The Arduino Code /* AnalogReadSerial Reads an analog input on pin 0, prints the result to the serial monitor. Graphical representation is available using serial plotter (Tools > Serial Plotter menu) Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground. This example code is in the public domain. */ // the setup routine runs once when you press reset: void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); } // the loop routine runs over and over again forever: void loop() { // read the input on analog pin 0: int sensorValue = analogRead(A0); // print out the value you read: Serial.println(sensorValue); delay(1); // delay in between reads for stability } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 /* AnalogReadSerial Reads an analog input on pin 0, prints the result to the serial monitor. Graphical representation is available using serial plotter (Tools > Serial Plotter menu) Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground. This example code is in the public domain. */ // the setup routine runs once when you press reset: void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); } // the loop routine runs over and over again forever: void loop() { // read the input on analog pin 0: int sensorValue = analogRead(A0); // print out the value you read: Serial.println(sensorValue); delay(1); // delay in between reads for stability } Discuss the Sketch This sketch starts with a multi-line comment describing the sketch and the circuit. You will probably notice that the first block of code is the setup() function – we do not declare or initialize any variables at the beginning of this sketch – instead we will do this inside the loop() function, as in the last example. Inside the curly braces of setup() we revisit the Serial library and use the function Serial.begin(). void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); } 1 2 3 4 5 6 7 void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); } If you recall from the last lesson, Serial.begin() takes the baud rate as an argument (this will almost always be 9600). This function allows you to setup a communication channel between the computer and the Arduino. As you may know by now, setup() only runs once, and then we move on to the next block of code. But wait! Don't we have to set the mode of the pin we will be using? Great point! What the Arduino does, by default, is set all the pins on the board as INPUTs unless you tell it otherwise. So in many cases, you do not have to explicitly set a pin as an input using the pinMode() function. That being said – I make it a habit to do this anyway – because it makes things clear to me – and that is worth it in space and effort. So I dare you, set the mode of the pin using the pinMode(A0, INPUT) function inside the curly braces of setup()– you won't regret it. Moving on to the loop() function, we start with a variable declaration and initialization. int sensorValue = analog

Mar 11, 201712 min