Abstract
Have you ever seen night lights that automatically turn on when it gets dark? What about art projects, like paintings or sculptures, with embedded lights? This project will let you combine the two, by adding lights to an art project of your choice. You can make the lights automatically turn on when it gets dark using a Raspberry Pi. Check out the video to see what this simple, but fun, project looks like:Summary

Introduction
A Raspberry Pi (Figure 1) is a tiny computer that you can use to write programs and build and control your own electronic circuits, like the light-sensing circuit in this project. The circuit uses sensors to gather information from the world around it. You can use information from those sensors to tell your computer program what to do. Many electronic devices we use every day, like phones and video game controllers, use sensors in the same way.

Figure 1. A Raspberry Pi computer. (Image credit SparkFun Electronics, licensed under Creative Commons Attribution 2.0).
You can do this project just for fun, or turn it into an engineering or science project. To make it an engineering project, you will need to follow the engineering design process. Start by defining what you want your darkness-activated art project to be able to do, then work through the rest of the design process until you have a completed project to show off at your science fair.
If you want to use this for a science project, you will need to follow the scientific method. Start by coming up with a question for which you can use the art project as a tool to help answer. For example, how sensitive is the light sensor to different lighting conditions? At what threshold will it cause your project's lights to turn on or off? How do people of different ages interact with the art?
Bibliography
- Raspberry Pi Foundation (n.d.). Teach, Learn, and Make with Raspberry Pi - Raspberry Pi. Retrieved August 28, 2019.
- lady ada (n.d.). Photocells. Adafruit. Retrieved August 28, 2019.
- Science Buddies (n.d.). Raspberry Pi Setup. Retrieved August 28, 2019.
Materials and Equipment

If you already have access to a Raspberry Pi, read through the Procedure to see the additional parts you will need to build the circuit.
Experimental Procedure
Introduction
In this project, you can let your artistic side "shine" by lighting up a drawing, painting, or sculpture. You will add LEDs to a piece of art that will automatically turn on when the room gets dark. If you have not already, you will need to set up your Raspberry Pi before you begin. Watch this video for a demonstration:
Writing Your Program
If you have never written a program in Scratch before, watch this video to learn how:
The program for this project uses a loop to constantly monitor a GPIO pin that is connected to the light sensor. Depending on whether that GPIO pin is high or low, it uses other GPIO pins to turn the LEDs on or off. Create the following program in Scratch. Be careful: this program uses the if/else block, which is not the same as the if block.

Figure 2
Building Your Circuit
To build your circuit, you will need to use a breadboard. If you have not used a breadboard before, watch this video before you continue:
To build the circuit for this project, you will need your male-male (M-M) jumper wires, LEDs (colors of your choice), and resistors. If you have not done the Build an Electronic Piano with a Raspberry Pi project yet, that is a good place to start to learn about these circuit components.
![]() Figure 3 |
![]() Figure 4 |
![]() Figure 5 |
You will also need the light sensor, which looks like this:

Figure 6
Connect everything to the breadboard, as shown in Figure 7.
Part | Picture Reference | First Hole | Second Hole |
---|---|---|---|
Red LED | ![]() |
F20 (long lead) | E20 (short lead) |
Green LED | ![]() |
F23 (long lead) | E23 (short lead) |
Blue LED | ![]() |
F26 (long lead) | E26 (short lead) |
Yellow LED | ![]() |
F29 (long lead) | E29 (short lead) |
Black M-M jumper wire | ![]() |
A17 (Pi Wedge GND) | Ground bus (left side) |
Red M-M jumper wire | ![]() |
J5 (Pi Wedge G22) | J20 |
Green M-M jumper wire | ![]() |
J6 (Pi Wedge G23) | J23 |
Blue M-M jumper wire | ![]() |
J7 (Pi Wedge G24) | J26 |
Yellow M-M jumper wire | ![]() |
J8 (Pi Wedge G25) | J29 |
Resistor | ![]() |
A20 | Ground bus (left side) |
Resistor | ![]() |
A23 | Ground bus (left side) |
Resistor | ![]() |
A26 | Ground bus (left side) |
Resistor | ![]() |
A29 | Ground bus (left side) |
Light sensor | ![]() |
A7 (Pi Wedge G4) | Ground bus (left side) |

Figure 7
Your circuit should now look like this:

Figure 8
Testing Your Program on the Breadboard
It is a good idea to make sure your program and circuit are working while you have everything assembled on the breadboard, before you start connecting things to your art project. Run your program by clicking the green flag towards the top of the Scratch window. Nothing should happen, which is good! The LEDs are supposed to turn on automatically when it is dark. Now, turn off all the lights in the room, and close the blinds on any windows. The LEDs should automatically turn on. If this works, you are ready to connect the LEDs to your artwork.
If you are in a room where you cannot reduce the light levels very much (for example, a room with a skylight, or without blinds or curtains on the windows), try covering the light sensor with your finger or your entire hand, or covering the sensor with an opaque object like a plastic cup. This will block light from reaching the sensor, and should cause the LEDs to turn on.

Figure 9
Creating Your Art and Connecting the LEDs
Once you are sure that your program and circuit are working correctly, you are ready to connect the LEDs to your art project. You can do this using the male-female (M-F) jumper wires from your kit. The M-F jumper wires are longer than the M-M wires, and they only have a metal pin on one end.

Figure 10
You can connect an LED to the jumper wires by pressing the leads of the LED into the female ends of two wires, as shown below. The wires' grip on the LED is not super tight, and the LED may fall out if you tug on it gently or when you move your artwork around, so it helps to use a piece of tape to secure the LED to the wires.

Figure 11
This video shows you how to securely attach the LEDs to your art project and the female ends of your M-F leads:
As you saw in the video, you need two M-F leads for each LED. Attach the female ends, as shown in the video above. Then, you will need to plug the male ends of the jumper wires back into the same breadboard holes where the LEDs' leads were originally. Here is a simplified diagram that just shows the red LED. On the left is the original connection with the LED directly in the breadboard. On the right, the LED is connected with jumper wires. It is still important to connect the LED's long lead to hole F20, and the LED's short lead to hole E20.

Figure 12

Figure 13
Here is a picture of all four LEDs connected to an art project. Be careful, those long jumper wires can get tangled!

Figure 14
Now, run your program again by clicking the green flag. Turn off the lights in the room (and close doors and windows if necessary), and your LEDs should light up your artwork!

Figure 15
Going Further
Your imagination is the only limit with what you can do with the Raspberry Pi and your artwork. Here are a few ideas.
- Make the LEDs flash or blink instead of just staying on all the time. You can do this by putting wait commands in between turning the LEDs on and off.
- Make your program play sound effects when the LEDs change status from on to off, or vice versa. It will be a bit of a programming challenge to figure out how to make the sound only play once, instead of over and over again. You can skip ahead to the Invent an Interactive Toy with a Raspberry Pi project if you want to figure out the Scratch code to do this.
- Use the motion sensor to make your artwork interactive. For example, you could make the program flash the LEDs or play a sound when a visitor walks by. See the Make a Motion Sensor Alarm with a Raspberry Pi project for instructions on using the motion sensor.
Troubleshooting
For troubleshooting tips, please read our FAQ: Create Light Up Artwork with a Raspberry Pi.

Ask an Expert
Frequently Asked Questions (FAQ)
Kit General Questions
- Who is the kit appropriate for?
- Are the kit parts reusable?
- Aren't there other Raspberry Pi kits on the market? How is yours different?
- I already have a Raspberry Pi. Can I just buy the circuit parts separately?
- What programming language do the projects use?
Setting Up and Using Your Raspberry Pi FAQ
- How do I connect my Raspberry Pi to my TV or computer monitor?
- Can I use a laptop as a display and/or keyboard?
- How do I connect my Raspberry Pi to the internet?
- How do I shut down or reboot my Raspberry Pi? There's no power button!
- How can I adjust the Raspberry Pi's display resolution?
- I have everything connected properly, why can't I hear any sound?
- Why won't my Raspberry Pi turn on?
- My Raspberry Pi starts to boot up, but then it freezes or the screen goes blank. What is wrong?
- My Raspberry Pi froze and is not responding to mouse or keyboard input. What should I do?
- My Raspberry Pi is acting strangely (it suddenly will not boot up properly, certain programs do not work, etcetera). What is wrong?
- I think I corrupted my Raspberry Pi's SD card. What should I do?
- I need help with a question, related to my Science Buddies Raspberry Pi Projects Kit or Raspberry Pi Circuits Parts Only Kit, not listed here. Who can I ask?
Kit General Answers
Q: Who is the kit appropriate for?A: The kit is meant for anyone (ages 8 and up) who wants to learn some basic programming and electronics skills while having fun. Students up to age 10, or older if their reading skills are behind grade level, may need adult assistance in reading and following the on-screen instructions. The projects included in the kit were beta tested and approved by students ages 8 to 16.
Q: Are the kit parts reusable?
A: Yes, all the electronics components in the kit can be re-used to do new projects or to repeat the projects.
Q: Aren't there other Raspberry Pi kits on the market? How is yours different?
A: Yes, there are other Raspberry Pi kits, and some of them are quite good! The Raspberry Pi Projects Kit and Raspberry Pi Circuit Parts Only Kit have been designed to contain the specific materials needed to do the accompanying Science Buddies Raspberry Pi projects. Our kit and associated projects are specifically meant for people who have no prior experience programming or connecting circuits. The projects are 100% beginner friendly with clear on-screen instructions, pictures, and videos. We think the kit, with its associated projects, is one of the most fun kits out there! But, if you are already an ace programmer or electronics guru, you may not find this the best fit for your own personal use. Even so, it may be a fun way for you to introduce others to programming and electronics.
Q: I already have a Raspberry Pi. Can I just buy the circuit parts separately?
A: Yes! We sell two different kits: the Raspberry Pi Projects Kit which includes a Raspberry Pi and the required accessories, and the Raspberry Pi Circuit Parts Only Kit, which only contains the additional circuit parts you need to do the Science Buddies projects. Both kits contain an SD card with the Raspbian operating system and a desktop shortcut to the Science Buddies project instructions.
Q: What programming language do the projects use?
A: The projects use Scratch 2. Scratch is a "graphical" programming language developed by the MIT Media Lab. It allows you to write code by clicking, dragging, and snapping together color-coded blocks. This allows beginners to write working code without worrying about formatting or typos. On the Raspberry Pi, Scratch allows you to control the general purpose input and output (GPIO) pins so your program can interact with a circuit in the physical world.
Note: three different versions of Scratch (1, 2, and 3) are available for the Raspberry Pi. The instructions for the Science Buddies projects (including example code) are specifically written for Scratch 2, which runs well on the Raspberry Pi model 3B+. If you have an older model Raspberry Pi, Scratch 2 may run more slowly, or may not run at all. If you want to use a different version of Scratch, you will need to consult the official documentation for Scratch 1.4 or Scratch 3 and modify the programming steps accordingly.
Setting Up and Using Your Raspberry Pi FAQ Answers
Q: How do I connect my Raspberry Pi to my TV or computer monitor?A: The easiest way to set up your Raspberry Pi is to use an HDMI cable (included in the Science Buddies Raspberry Pi Projects Kit) to connect to a TV or computer monitor that has built-in speakers. If you are using a computer monitor with an HDMI port but no built-in speakers, you will also need separate speakers or headphones with a 3.5 mm audio plug (a regular "headphone jack").
If your TV or monitor does not have an HDMI port, you will need an HDMI to DVI or HDMI to VGA adapter (see pictures in table below). DVI and VGA do not transmit sound, so you will need separate headphones or speakers if you are using one of those options.
HDMI | DVI | VGA |
---|---|---|
![]() |
![]() |
![]() |
Q: Can I use a laptop as a display and/or keyboard?
A: The short answer is "not easily." Many newer laptops have HDMI ports, but they only function as HDMI out, to send a video signal from the laptop to a television or projector. They do not work as HDMI in to display an external signal on the laptop's screen. The laptop's keyboard is only designed to work with the laptop itself, not as a standalone keyboard for an external device like the Raspberry Pi.
The longer answer is that, similar to the Remote Desktop feature on Windows and Mac computers, you can use special software to remotely operate a Raspberry Pi that is connected to the internet. This would allow you to control a Raspberry Pi using your laptop's screen and keyboard. This option is only recommended for advanced users, and you can find instructions at Raspberry Pi Documentation.
Q: How do I connect my Raspberry Pi to the internet?
A: Unlike earlier models, the Raspberry Pi 3B+ contains built-in Wi-Fi functionality. It does not require an external USB Wi-Fi adapter. You can connect your Raspberry Pi to the internet by clicking the internet icon in the taskbar and searching for available Wi-Fi networks, just like you would on a Windows or Mac computer. Your Raspberry Pi also has an ethernet port, which you can use to plug directly into a router for a hardwired connection.
Q: How do I shut down or reboot my Raspberry Pi? There's no power button!
A: Unlike most computers, the Raspberry Pi does not have a power button. You can shut down or reboot by clicking the raspberry icon in the upper left corner of your desktop, then select Shutdown. After the Raspberry Pi has shut down, it is safe to unplug the micro-USB power cable. Plug the cable back in to reboot. Important: never unplug the power cable while the Raspberry Pi is still running. This can corrupt the SD card.
Q: How can I adjust the Raspberry Pi's display resolution?
A: Click the Raspberry Pi logo in the top-left corner of your desktop. Select Preferences, then Raspberry Pi Configuration, then click the Set Resolution... button on the System tab.
Q: I have everything connected properly. Why can't I hear any sound?
A: Right-click the speaker icon on the desktop taskbar. This allows you to manually select HDMI or analog (the headphone jack) for sound output. Make sure you have the proper output selected. Also, make sure your Scratch program is set to play a sound. You can write a simple program to test if your sound is working using the "when space key pressed" and "play sound meow" blocks.
Q: Why won't my Raspberry Pi turn on?
A: If your Raspberry Pi will not turn on (the screen remains blank after everything is plugged in), go through this checklist to make sure everything is set up properly.
- Make sure your SD card is pushed in all the way (see Figure 1).
- Make sure the red power LED on your Raspberry Pi (labeled "PWR," near the micro-USB port, see Figure 2) is on. This means the Raspberry Pi is receiving power from the micro-USB port. If the LED is not on, make sure you pushed the micro-USB connector into the micro-USB port all the way.
- When you first plug the micro-USB cable in, the green LED (labeled "ACT," next to the PWR LED, see Figure 2) should flash several times. This LED flashes when the Raspberry Pi reads data from the SD card. After the Raspberry Pi is done booting up, it should turn off. If it does not flash at all, your SD card might not be inserted properly. Go back to step 1.
- Make sure your display (television or monitor) is turned on. If your display is turned off, you will not see anything on the screen, even if the Raspberry Pi is on.
- Make sure your display is set to the correct input. Many modern TVs have more than one HDMI input, and some computer monitors have DVI or VGA inputs in addition to HDMI.

Figure 1. A micro-SD card that is inserted properly (left) and one that is not pushed in all the way (right).

Figure 2. The PWR (red) and ACT (green) LEDs near the micro-USB port.
Q: My Raspberry Pi starts to boot up, but then it freezes or the screen goes blank. What is wrong?
A There may be a problem with your Raspberry Pi or SD card. If you are using the Raspberry Pi or SD card that came with the Raspberry Pi Projects Kit or Raspberry Pi Circuit Parts Only Kit purchased from our partner Home Science Tools, please contact them directly at service@homesciencetools.com for assistance.
Q: My Raspberry Pi froze and is not responding to mouse or keyboard input. What should I do?
A: First, be patient and give the Raspberry Pi a few minutes to try and process whatever it was doing. If you click on a whole bunch of things in rapid succession, or run a really complicated Scratch program, the Raspberry Pi might slow down or freeze temporarily.
Next, if you are using a wireless keyboard and mouse, make sure they have fresh batteries.
Finally, as a last resort, if your Raspberry Pi is not responding, unplug the micro-USB cable and plug it back in. In general, you want to avoid doing this, because suddenly cutting power to the Raspberry Pi without properly shutting it down first can corrupt the SD card, and prevent the Raspberry Pi from working properly.
Q: My Raspberry Pi is acting strangely (e.g. it suddenly will not boot up properly, certain programs do not work, etc.). What is wrong?
A: If your Raspberry Pi is not "dead," but seems to be behaving strangely, there is a chance that your SD card has become corrupted. This can happen if you unplug the Raspberry Pi's power cord without properly shutting it down first. See the next question.
Q: I think I corrupted my Raspberry Pi's SD card. What should I do?
A: If the SD card came with the Raspberry Pi Projects Kit or Raspberry Pi Circuit Parts Only Kit you purchased from our partner Home Science Tools, please contact them directly at service@homesciencetools.com for assistance. Make sure to include a detailed description of the problem you are having. They will work with you to resolve the issue.
Careers
If you like this project, you might enjoy exploring these related careers:
Related Links
- Science Fair Project Guide
- Other Ideas Like This
- Computer Science Project Ideas
- Electricity & Electronics Project Ideas
- My Favorites