Going From LED to Sensor in Less Than 60 Minutes!
Notice. This guide has recently changed to use Codebender instead of the Arduino IDE. If you would like to review the old guide which uses the IDE you can access it here.
So you have an Ardusat Space 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, all the way through interacting with the luminosity sensor.
What do you need to be able to do by the end of this tutorial? There are at least four critical skills that you should be able to do on your own.
- Identify the parts of the space kit
- Follow a simple wiring diagram
- Upload Arduino code to an Arduino
- Connect the Arduino to the Ardusat Experiment Platform
For the getting started activities you are going to need the following parts from the Space Kit.
- (A) 1 Arduino Uno
- (B) 15 Jumper wires
- (C) 1 Breadboard
- (D) 6 Resistors (Red - Red - Brown - Gold)
- (E) 1 IR Thermopile
- (F) 9 LEDs (Any color)
- (G) 1 IMU sensor
- (H) 1 UV sensor
- (I) 1 Luminosity sensor
- (J) 1 Temperature sensor
- (K) 1 USB cable
- (L) 1 Photoresistor
Can you identify all the parts of the Space Kit? If not, you might want to check out our unboxing video!
Can you recognize all of the different parts of your kit? Get them all laid out, and let's take this mission to space!
There are several free and easy ways to install the software that we will use to load code onto the Arduino. You can install the Arduino IDE along with our SDK libraries, but there is an even easier way then that! This getting started guide will use a tool called Codebender!
Codebender is a website that allows us to load our software library into their website and then embed the code here on this page. All you need to do is install the plugin and then connect your Arduino to your computer.
Note #1: You'll need to have an Arduino connected to the computer via the included USB cable to finish the walkthrough. When you are finished and confirm that everything is working, you can move on.
Note #2: You will need to have permissions on the computer you are using to be able to install this plugin. It might even already be installed. If you do not have permission to install on a school computer you should contact your school or district's technology support staff.
Note #3: If you prefer you can install the Arduino IDE software and add the Ardusat SDK library.
Did Codebender work? Were you able to make it to step 5 in the Codebender walkthrough? If so, you are good to move on to our next activity.
What is an Arduino Uno? An Arduino is an open-source electronics platform based on easy-to-use hardware and software. It is often referred to as a "microcontroller". It's intended for anyone making interactive projects. (http://www.arduino.cc)
An Arduino is an ideal development tool because of how easy it is to connect input and output devices.
1. Plug one end of the USB cable into the USB port on the Arduino (if it isn't already).
2. Take the other end of the USB cable and plug it into a USB port on your computer (if it isn't already). Ignore any messages that read the Arduino as an “Unregistered Device”.
3. If you’re the first person to use your Arduino, you can skip step 4.
4. Below is the code that will need to run on your Arduino for the Blinking Light sketch to work. Most Arduinos come with this code pre-loaded on it. Make sure the correct board is selected, it should be set to Arduino Uno. Also make sure the port is set to the correct USB port on your computer.
5. Double check that your Arduino and port are correct and click the "Run on Arduino" button. ↑
6. Watch the onboard LED next to pin 13 blink on and off.
Note #3: An Arduino code or program is referred to as a "sketch".
Have you dared to awaken the Arduino Uno? If the monster has opened it's eyes, let's make an LED come alive.
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.
A breadboard is a tool used for quickly and easily building circuits.
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.
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.
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!
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, two jumper wires and a 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 red 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
- 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.
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.
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.
Is your LED as constant as a light saber? Let's use the Force to control that shine with just one finger.
In this activity, we will introduce the photoresistor. This sensor detects light and dark. The less light it detects, the less 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!
1. Plug your Arduino into your computer (if it isn’t already.)
2. Remove the resistor from the circuit.
3. Take one end of the photoresistor and plug it into Column E, Row 12 on the left side of the breadboard.
4. 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.
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.
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.
- Make sure the Codebender window below shows that your Arduino Uno is selected and connected to the correct port. Click the "Edit" button at the top of the code bender window below.
- Find the lines that read delay(1000);
- Change 1000 to 100 on both lines.
- Click on the "Run on Arduino" button at the bottom of the Codebender window.
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?
Note #4: The purpose of this activity is to demonstrate how easy code is to edit. You don't need to understand every line of code to be able to successfully change and adjust a few parts of it.
Note #5: If you are interested in learning more about coding in Arduino, we recommend the following video series https://www.youtube.com/watch?v=09zfRaLEasY by the Open Source Hardware Group. However, for the purpose of this activity you don't need to know very much about coding in Arduino to get the results you are looking for.
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.
...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.
- Use the Codebender window below to upload the "Fade" sketch onto your Arduino.
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.
Feel like you've done everything you possibly can with an LED? Let's give it some buddies to share in the fun.
What if we want more LEDs to light up all at the same time? Consider it done!
- 1. Get two more red LEDs and unplug the red LED that was plugged in.
- 2. Add a resistor (the same one we used earlier) by plugging one end into the positive rail on the right side of the breadboard.
- 3. Connect the other end of the resistor into column “I” on the same row.
- 4. Double check that the red jumper wire is still connected to pin 9.
- 5. Connect the free end of the red jumper wire to column F on the same row as the resistor.
- 6. 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.
- 7. 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!
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.
Get the parts you’ll need along with your breadboard and Arduino.
- 3 resistors (220 ohm; Red - Red - Brown - Gold)
- 1 black jumper wire
- 3 jumper wires (any color)
- 3 LEDs (any color)
Follow the wiring diagram 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. We'll use the Blink sketch from Codebender below.
- Now, let’s change the code above by clicking on the "Edit" button. We need to change it to work with Pin 11 instead of pin 13. Find the line "int LED = 13; 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.
Next, let’s get the rest of the lights blinking. What do you think is the easiest way to do this? Do you think you could do this on your own without help?
Try editing the code above to get it to work. Remember we need to get pin 10 and 9 also working. If you are feeling stuck or don't need to learn how to code you can use the code below to get the rest of the lights to turn on and off.
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! When you’re ready, begin part 2.
Now that you’ve had some fun with outputs from the Arduino, lets have some fun collecting data with a sensor. The Ardusat Space Kit comes with 4 different sensor boards and one that measures 14 different types of data. In this activity we will be using the luminosity sensor. After we wire up the sensor we will load a sketch from the Ardusat Software Development Kit (SDK) and check out the data on the Ardusat Experiment Platform.
Gather all the hardware you are going to need.
- 6 jumper wires
- 2 Red
- 2 Black
- 1 Yellow
- 1 Green
- Luminosity Sensor
- Arduino and USB cable
Make sure you have all of the necessary equipment handy before you start this space mission.
Wire the luminosity sensor by either watching the video or follow the diagram below.
Watch the wiring video above or follow the wiring diagram below to wire the sensor.
Got all of your wires in the right place with your sensor? Double check with the diagram. Now you know which wire to cut if a motherboard of computers decides to take over the world and you need to disarm it. Well, maybe not, but you can wire up a luminosity sensor.
Now it's time to get the sketch (or code) that will collect data from the luminosity sensor. Ardusat has already written the code, all you need to do is upload it.
Choose the correct com port for for the Arduino (if it isn’t already).
Upload the Luminosity sketch to the Arduino by clicking the Upload button.
View the data coming from the "Serial Monitor" using the field below.
Can you see your own data coming through the Serial Monitor? Pretty cool, huh? Don't worry too much, we are going to show you another way to see your sensor data . . . through the Ardusat Experiment Platform.
You're basically a luminosity scientist now. Make sure you close down the serial monitor before starting this next step.
The Ardusat Experiment Platform is a tool that can be used to collect data from an Arduino, visualize that data, discover other datasets, and write an experiment that can be shared online. We are going to cover how to login, install the chrome app, connect an Arduino to the Experiment Platform, and collecting data.
Go to the Experiment Platform page in the Chrome Browser. If you don't have Chrome, you'll need to get it installed. A simple Google Search for Chrome should make this easy.
The Experiment Platform requires a small plugin get installed the first time you connect to the experiment platform. Installing the Experiment Platform Plugin, it's easy!
- Click on the "Connect" link on the Experiment Platform. If the plugin has not been installed you'll see an "Install" button. Keep in mind that permissions might be required to install the computer you are on.
- Click on the Install button.
- Click on the "Add App" button that will pop up in Chrome.
Warning! A common problem is being connected via the serial connection in Codebender (or software like the Arduino IDE) while trying to connect to the Experiment Platform. Your Arduino can only be connected to one serial connection. Be sure that the Arduino has been disconnected from Codebender otherwise you are likely to experience a connection error.
Click on the Connect menu on the left side of the Experiment Platform Dashboard page. ,
- Chose the correct port.
- Leave the rest of the settings as default.
- Finally, click the Green "Connect" button.
Look at your Live data feed!
Once you are in you can go to the “all sensors” view. It occasionally takes a few seconds to begin reading data, but you should shortly begin to see a chart with luminosity data. Hold your hand over the sensor and notice the change.
Log data using the Data Logging tool. The Data Logging tool will create a CSV file which can be opened using Microsoft Excel. Log data for about 20 seconds. While it is logging slowly hold your hand over the luminosity sensor. Stop logging data and open the CSV in Microsoft Excel if you have it installed on your computer. Take a look at the data and see if you can identify the darkest moment in the data.
Still couldn't get your Arduino to connect? Don't forget to close down the Serial Monitor or Arduino if you still can't get it to work. Then try launching the experiment platform again. You will only have one graph unlike the computer shot here that seems to be going a little cray cray.
Let’s create something that puts together the input from a sensor and the output of an LED.
Add an LED to your Luminosity Sensor circuit following the diagram below.
Write the following code and upload it to your Arduino. What do you think this code will do?
How would you change the code so the light turns on sooner (does not require it to be as dark)?
How would you change the code if you were connected to pin 9 instead of 13?
Try wiring up each sensor and connect them to the experiment platform
This work by Ardusat is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License based on a work at ardusat.com.