A collage of images showing various led lights connected to a breadboard lighting up.


In this activity, students will build and code a device capable of detecting and measuring light from several light sources. Each light source will emit light at a different wavelength but only one wavelength contains the information students will need to collect. Students will write a program that enables their device to selectively detect only the desired light source.



  • This activity requires an intermediate knowledge of programming languages. Students should have background knowledge of how to import libraries for external sensors using Python and navigate online resources for operating loops.
  • If materials allow, try to keep groups no greater than three students. This way, each student can have a specific role (e.g., programming, assembly, or optics) that can be performed concurrently with the group to ensure active group participation.


As we explore the solar system and beyond, we rely on NASA’s Deep Space Network, or DSN, to serve as our communication device between Earth and our distant spacecraft. The DSN consists of a number of antennas across the globe that use radio waves to transmit information to and receive data from our missions in space.

NASA experts talk about the system of antennas that make up the Deep Space Network and how it's used to communicate with distant spacecraft and collect science. | Watch on YouTube

However, radio waves are not very efficient when it comes to transmitting a lot of information in a short amount of time. Their long wavelengths mean that signals can better resist distortion, but as more and more complex data is being sent across space, NASA is exploring higher frequency (and therefore shorter wavelength) light sources to be able to beam messages more efficiently.

Infrared light is shown to the left of visible light with icons indicating that remote controls and human body heat fall into this portion of the electromagnetic spectrum.

This diagram shows wavelengths of light on the electromagnetic spectrum and how they're used for various applications. Image credit: NASA | + Expand image

One such option being explored is known as Deep Space Optical Communications, or DSOC, which would use near infrared (NIR) light beams carefully aimed between spacecraft and our detectors on Earth to send data. By using IR light instead of radio waves, we would see a 10,000-fold increase in frequency meaning 100-times more data could be transmitted.

A giant antenna dish is shown in a desert landscape as the sun is setting.

This artist's concept shows what a new antenna dish capable of supporting both radio wave and laser communications, will look like when completed at the Deep Space Network's Goldstone, California, complex. Image credit: NASA/JPL-Caltech | + Expand image

While this would mean we could get more data more rapidly, it does come with some complications. Light doesn’t move equally through different materials. This is why our sky is blue and why we build telescopes on top of high mountains. The atmosphere interferes with certain wavelengths of light, potentially distorting the data being received.

Additionally, recall that we receive much more than visible light here on Earth. We are bathed in light beyond what we can detect with the naked eye, such as ultraviolet light from the Sun or radio waves from our phones and wireless internet.

To be successful, DSOC technology will need to be capable of resisting distortion as the light travels through space and our atmosphere, selective about the wavelength of light it detects, and carefully positioned to catch a focused beam of light. So far, it appears this all could be achievable. The DSOC technology has already been piloted in communications between Earth and the Moon and will next be tested aboard the Psyche mission, launching in 2022.


Setup and Programming

  1. Using a compatible computing device and a desired programming language, such as Python, import the libraries needed for your device. This will likely include GPIO board, LEDs, and more, depending on student knowledge of coding and the devices being used (LEGO, Raspberry Pi, Cubit, etc.).
  2. Have students begin by writing a simple script capable of turning on and off at least three lights. It’s recommended that the lights have very different wavelengths, such as IR, visible light, and UV.
  3. Have students experiment with code that will use a light sensor to detect one of these lights but not the others. This can be done using the intensity detected by the sensor, for example.
  4. Instruct students to write code that gives an output for whether or not the desired wavelength of light is being detected. If students have a digital display, for example, this can be as simple as printing out the message “Receiving.” Consider adding more indicators of success, such as triggering a speaker.
  5. The most difficult step is writing the code to run both the light display sequence and the detection sequence concurrently. This can be done by joining multiple loops or using the "multiprocessing" and "process" libraries. Sample code is shown below, but have students experiment in creative ways, including potentially doing some online research about various techniques they might use, as this is the most flexible step towards success.

Device Construction

  1. To build the physical device, students will need at least a breadboard, three LEDs, and a light sensor. Depending on the devices being used, they may need wires and resistors for each LED.
  2. Have students put together an inventory and blueprint of their physical device and gather materials. Dividing team members to include specific groups roles will help to keep all students engaged. Encourage students to communicate with their programming and optics counterparts on their team to be sure they are all operating with the same supplies in mind.
  3. Begin construction of the device by having students align the LEDs on the breadboard either an equal distance from the light detector or in a way that the LEDs can be easily moved to a standard distance.
  4. Once the sample code is ready for testing, verify that the lights are operating (See step 2), students should verify that the LEDs are properly connected via their individual assemblies. Remind students that, depending on the wavelengths chosen, they may not be able to actually see that the LED is operating.
  5. Have students responsible for construction communicate with their programming counterpart to record the intensities of each light being detected. Students should revise their code and threshold for detection based on these observations.
  6. Challenge students to attach a digital display and/or a speaker to their device that is triggered when the correct wavelength is detected above the threshold intensity.
  7. Execute the code, and revise as needed.


  • What challenges presented themselves in running two loops simultaneously? How was that resolved?
  • How do we know that the light detector is capable of detecting the wavelengths of all of our LEDs? Was there a scenario where you were able to trigger the sensor with the UV light? The IR light?
  • What possible complications do you predict would present themselves as we translate our device from lights and detectors in close proximity to those spread across the solar system?


  • Refer to the coding rubric.

  • A successful project will have at least three LEDs cycling while simultaneously and reliably indicating detection of light when only the desired light is illuminated.


  • If you have an IR camera available, an exciting demonstration and extension is to show students what their active device looks like under an IR camera instead of with the naked eye. Per the discussion above around complications of detecting light across the solar system, certain materials, such as plexiglass, block IR light.
  • If student groups finish their device quickly, consider having them switch their light detector with an IR diode sensor. These simple devices cost under a dollar and can be used to selectively identify IR light instead of visible light.

Explore More