Introduction: Getting Started With Arduino in 60 Minutes
So you have an Ardusat Space Kit (or other Arduino Starter Kit), now what?
Good question. The foundational knowledge that allows learners to create experiments in space starts with the humble LED. These instructions will take you from getting a single LED to blink, to several LEDs going on and off.
Step 1: Collect the Parts
For the getting started activities you are going to need the following parts from your Arduino Starter Kit. If you don't have a kit, you can purchase the Ardusat Space Kit here: http://store.ardusat.com/collections/frontpage/pro... The Ardusat Space Kit comes with several sensors which we will not be using in this instructable, but they are featured in the video and images. To learn more about the projects you can make with the sensors, check out our learning resources here: https://www.ardusat.com/lessons
- (A) 1 Arduino Uno
- (B) 15 Jumper wires
- (C) 1 Breadboard
- (D) 6 Resistors (Red - Red - Brown - Gold)
- (F) 9 LEDs (Any color)
- (K) 1 USB cable
- (L) 1 Photoresistor
Step 2: Install the Arduino IDE
Installing software isn’t always fun, but getting these programs installed, and setup correctly is an important step in getting your Arduino and Space Kit working!
Download the Arduino integrated development environment (IDE) from
http://arduino.cc/en/Main/Software
Choose the correct version for the computer you will be using
Windows- Choose the “Windows Installer.”
Mac- Download the Mac OS X file
Install the IDE software.
Windows- Double-click the downloaded Arduino .exe file from the download folder, follow the prompts to finish installation.
Mac- Double-click the .zip file from your download folder, drag to the Applications folder.
Ready for the next activity?
Can you see the Arduino icon on your screen? If you're curious about what it is, move on to activity three.
Step 3: Simplest Blink
What is an Arduino Uno? An Arduino is an open-source electronics platform based on easy-to-use hardware and software. It's intended for anyone making interactive projects. (http://www.arduino.cc)
An Arduino is an ideal development tool because of how easily they connect to input and output devices.
- Plug one end of the USB cable into the USB port on the Arduino.
- Take the other end of the USB cable and plug it into a USB port on your computer. (Ignore any messages that read the Arduino as an “Unregistered Device”)
- If you’re the first person to use your Arduino, skip steps 4 - 8.
- Open the Arduino IDE software you installed earlier.
- Click Tools → Board → Arduino Uno.
- Click Tools → Port → (Arduino Uno).
- Click File → Examples → 01.Basics → Blink.
- Click on the(upload) button to upload your code onto the Arduino. Wait for the progress bar in the lower-right corner of the Arduino IDE to fill indicating it’s finished uploading.
- Watch the onboard LED next to pin 13 blink on and off.
Ready for the next activity? Have you dared to awaken the Arduino Uno? If the monster has opened it's eyes, let's make an LED come alive.
Step 4: My First Circuit
Let’s bring in some more components to extend the blinking light and make an external LED blink. First, it is helpful to have a little background information about breadboards, resistors, and LEDs.
Breadboard A breadboard is a tool used for quickly and easily building circuits. Rails The outside columns are called rails. There are power and ground rails which are used for connecting power (voltage) and ground to the breadboard. Notice how the rails are all connected - this means that you can connect anywhere in the rail to connect to power.
Columns and Rows Notice there are also columns and rows in the middle of the breadboard. The rows are split down the middle and are connected to each other, but divided down the center. The columns are not connected to anything.
LED Light Emitting Diode (LED) is a small light. There are two legs that come out of the LED, a longer leg and a shorter leg. It is important to note which is which because the longer leg (or anode) needs to be connected to power and the shorter leg (or cathode) needs to be connected to ground. If this is backwards it could burn out! Resistors A resistor is used to slow the flow of electricity through a circuit. Too much electricity flowing through a circuit can cause damage to certain components so it is important to follow diagrams of when to use them. To learn more about resistors check out https://www.ardusat.com/lessons/86
Let’s create a circuit using the breadboard, LED, and Resistor.
- Take one end of a black jumper wire and plug it into the GND pin on the right side of the Arduino.
- Connect the other end of the black jumper wire to the ground rail on the right-hand side of the breadboard.
- Take one end of a red jumper wire and plug it into PIN 13 on the Arduino.
- Connect the other end of the jumper wire and plug it into Column A, Row 12 on the left side of the breadboard.
- Take one end of a resistor and plug it into Column D, Row 12 on the left side of the breadboard.
- Connect the other end of the resistor into Column F, Row 12 on the right side of the breadboard.
- Take the positive end of an LED (the longer leg) and plug it into Column J, Row 12 on the right side of the breadboard.
- Connect the other end of the LED (the shorter leg) to the ground rail on the right side of the breadboard.
- If it isn’t already, plug the Arduino to your computer with the provided USB cable. If everything has gone correctly, you will have a circuit where the external LED is blinking on and off.
Ready for the next activity?
Are you currently basking in the warm glow of your oscillating digital candle?
If so, let's turn a candle into a flashlight with a more steady beam.
Step 5: Keep a Light on for Me
Now we have a blinking LED. Let’s see what happens when we plug the light straight to 3.3v of electricity.
- Disconnect the end of the red jumper that is currently connected to PIN 13 on the Arduino.
- Take the end of the red jumper wire you just disconnected from PIN 13 and connect it to the 3.3V pin on the left side of the Arduino.
The LED should now stay on continuously. In this case, the Arduino isn’t sending any signals to the LED, only providing 3.3 volts of electricity.
Ready for the next activity?
Is your LED as constant as a light saber?
Let's use the Force to control that shine with just one finger.
Step 6: Resistance Is Futile
In this activity, we will introduce the photoresistor. This sensor detects light and dark. The more light it detects, the more electricity it will allow to flow through. What do you think will happen when we replace the resistor in our circuit with the photoresistor?
Let’s find out!
- Plug your Arduino into your computer (if it isn’t already.)
- Remove the resistor from the circuit.
- Take one end of the photoresistor and plug it into Column E, Row 12 on the left side of the breadboard.
- Connect the other end of the photoresistor into Column F, Row 12 on the right side of the breadboard.
Cover the photoresistor with your finger, what happens to the LED? It should fade when you cover the photoresistor and brighten once it’s uncovered. If this is not the reaction you’re experiencing, double check your wiring.
Ready for the next activity? Have you mastered the power to bend the will of light with one finger? Then let's control it with some world saving code. Good news, we wrote it for you. You just get all of the credit.
Step 7: Become a Hacker
The previous activities familiarized us with the Arduino hardware and connecting various components. The next activity is to learn about the code that makes all the magic happen. In the Arduino world, programs are called ‘Sketches.’ Don’t be intimidated by the mention of big scary ‘code.’ You’ll be happily hacking away on your Arduino in no time. Here we go!
- Plug your Arduino into your computer (if it isn’t already.)
- Move one end of the red jumper wire from the 3.3v pin and plug it into PIN 13 on the right side of the Arduino.
- Replace the photoresistor with the regular resistor.
- Open the Arduino IDE software you installed earlier.
- Click Tools → Board → Arduino Uno.
- Click Tools → Port → (Arduino Uno).
- Click File → Examples → 01.Basics → Blink.
- Find the lines that read delay(1000);
- Change 1000 to 100 on both lines.
- Click on the(upload) button to upload your code onto the Arduino.
Wait for the progress bar in the lower-right corner of the Arduino IDE to fill indicating it’s finished uploading. The LED is now blinking much faster!
Change the numbers again. How low can you take the numbers before the light no longer seems to be blinking?
What happens when you change the numbers to different values?
Ready for the next activity?
Have you hacked your way into doing what Einstein himself could not? Control the speed of light?
If so, put those skills to good use and put a softer touch on things.
Step 8: It’s Better to Burn Out...
...than to fade away! We’re ready to use the Pulse Width Modulation (PWM) pins so we can make our LED gently fade on and off. In order for this to work, we’ll be switching pins on the Arduino again. For more information about the difference between Digital Pins and PWM Pins you can check out this article on Arduino.cc.
- Move one end of the red jumper wire from PIN 13 to PIN 9.
- Open the Arduino IDE software.
- Click File → Examples → 01.Basics → Fade.
- Click on the button to upload your code onto the Arduino.
- Wait for the progress bar in the lower-right corner of the Arduino IDE to fill indicating it’s finished uploading.
//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 code tells the Arduino to slowly ramp up the amount of electricity flowing through the circuit until it reaches maximum brightness then slowly ramp it back down in an infinite loop.
Ready for the next activity?
Feel like you've done everything you possibly can with an LED? Let's give it some buddies to share in the fun.
Step 9: Let There Be LEDs
What if we want more LEDs to light up all at the same time? Consider it done!
- Get two more red LEDs and unplug the red LED that was plugged in.
- Add a resistor (the same one we used earlier) by plugging one end into the positive rail on the right side of the breadboard.
- Connect the other end of the resistor into column “I” on the same row.
- Double check that the red jumper wire is still connected to pin 9.
- Connect the free end of the red jumper wire to column F on the same row as the resistor.
- Add the three red LEDs into the power (+) and ground (-) rails of the breadboard on rows 12, 17, and 24. Be sure that the long leg on the LED is plugged into the + rail and the shorter leg is connected to the ground rail.
- Add power by plugging the Arduino into your computer via the USB cable.
Do all three LEDs light up and fade together?
This is a parallel circuit. When the LEDs are connected like this they will be turned on and off together. What if you want to control each light on its own?
To figure this out, you are ready for Activity 10!
Ready for the next activity?
Do you feel as if you have created a small army of synchronized glowing lightening bugs?
If this feeling does not occur, try again and then move on so each LED can have it's own solo.
Step 10: Light Show
Get the parts you’ll need along with your breadboard and Arduino.
3 resistors (Red - Red - Brown - Gold)
1 black jumper wire
3 jumper wires (any color)
3 LEDs (any color)
Follow the wiring diagram below so that each LED is connected to its own PWM pin on the Arduino: 11, 10, and 6. The LEDs can go in any row.Now we need to write some code that will turn each light on and off.
Load the Blink sketch if it isn’t already open. File → Examples → Basics → Blink.
Now, let’s change the code to work for Pin 11. Find the three lines “pinMode (13, OUTPUT)” “digitalWrite(13, HIGH); “ and “digitalWrite(13, LOW); “ and change the 13 to 11.
Upload the sketch to the Arduino. You should now have the LED that is connected to the digital 11 pin blinking.
// the setup function runs once when you press reset or power the board
void setup() { pinMode(11, OUTPUT); //initialize digital pin 11 as an output. pinMode(10, OUTPUT); //initialize digital pin 10 as output. pinMode(6, OUTPUT); //initialize digital pin 6 as an output. } // the loop function runs over and over forever void loop() { digitalWrite(11, HIGH); // turn the LED on (HIGH is voltage level) delay(1000); // wait for a second digitalWrite(11, LOW); // turn voltage off by making voltage LOW delay(1000); // wait for a second digitalWrite(10, HIGH); // turn the LED on (HIGH is voltage level) delay(1000); // wait for a second digitalWrite(10, LOW); // turn voltage off by making voltage LOW delay(1000); // wait for a second digitalWrite(6, HIGH); // turn the LED on (HIGH os voltage level) delay(1000); // wait for a second digitalWrite(6, LOW); // turn voltage off by making voltage LOW delay(1000); // wait for a second }
What do you think is going to happen?
Did they light up in sequence?
Can you speed up the delay time so the lights blink faster?
Can you change the code so the lights bounce back and forth?
Great job! You’ve successfully made an LED blink, built a circuit, installed the Arduino IDE software and modified code, and made a bunch of LEDs outputs bend to your will!Happy cat approves!
Find more fun Arduino activities at: https://www.ardusat.com/lessons