Rainbow Light Refraction Machine: Explore the Spectrum With Arduino & Tinkercad!
by MrBennett703 in Circuits > Arduino
160 Views, 1 Favorites, 0 Comments
Rainbow Light Refraction Machine: Explore the Spectrum With Arduino & Tinkercad!

Unlock the Magic of Light!
Have you ever wondered how a rainbow appears after a rain shower? Or why a shiny CD can show you so many beautiful colors? In this exciting project, we're going to build our very own "Rainbow Light Refraction Machine" using an Arduino, a stepper motor, and a special prism. Get ready to create stunning light displays and discover the secrets behind the colors of light!
- What you'll learn:
- Basic Arduino programming and electronics.
- Designing a hardware case in Tinkercad.
- The fascinating science of light refraction and the color spectrum.
- How to make a room glow with your own colorful creation!
Supplies





Arduino Uno (or compatible board)
Small stepper motor (e.g., 28BYJ-48 with ULN2003 driver board), 2 small screws
Small glass or acrylic prism (ideally one that can be easily mounted) I found Mine here
Breadboard ( not necessary, but makes adding to the project easy.)
Jumper wires (male-to-male)
USB cable for Arduino
5V power supply (if not powered directly from USB)
TinkerCad Account, A 3D Printer or Cardboard (a Bar Of Soap Box works well) or small project box for enclosure
Hot glue gun or strong adhesive
Large LED spot light or Small LED flashlight or bright white LED (for diffusing light if ambient light isn't sufficient)
I found this light a "priceMark" you know one of those Amazon Return stores, and I got it for $2. I had no Idea the Thing cost $32.00?!! new, but here's the link if you want the same one.
The Science Behind the Rainbow - Unraveling the Spectrum

- What is Light?
- The Mystery of White Light:
- "Did you know?" Fact: Even though the light from the sun looks white, it's actually a combination of all the colors of the rainbow!
- Analogy: Think of white light like a mix of all the different colored M&Ms in a bag. When you open the bag, you see all the colors, but from far away, it just looks like a mix.
- How a Prism Creates a Rainbow (Light Refraction):
- When white light passes through a prism, it slows down and bends. Different colors of light bend at slightly different angles.
- Key Concept: Refraction: This bending of light is called "refraction."
- Analogy: Imagine different-sized cars driving through mud. They'll all slow down, but some might veer off course more than others, depending on their size and speed.
- Introducing the Color Spectrum: List the colors of the rainbow in order: Red, Orange, Yellow, Green, Blue, Indigo, Violet (ROYGBIV). These are the visible colors of light that our eyes can see.
- Who Discovered the Color Spectrum?
- Insightful Fact: "The brilliant scientist Sir Isaac Newton was the first to famously demonstrate that white light is made up of a spectrum of colors. In the late 1660s, he conducted groundbreaking experiments using prisms, showing that when white light passed through one prism, it separated into the different colors, and when those colors passed through a second prism, they combined back into white light. His work revolutionized our understanding of light and color!"
Gathering Your Supplies (The Maker's Toolkit)







Getting Your Measurements Right: Before we jump into Tinkercad, you'll need to measure all your components. Grab a ruler and carefully measure the length, width, and height of your: ( my measurements MIGHT be different from yours. Measure twice, Print once!)
- Arduino board
- Stepper motor driver board
- Stepper motor
- Prism
- Pro Tip: Remember to leave extra room in your design for all the wires! You don't want them to be squished.
Designing the Prism Mount:
- In Tinkercad, create a simple platform or holder that your prism can sit in securely.
- Design a small arm or connector that will attach this prism mount to the stepper motor shaft. This arm is what will make your prism spin!
- OR if you don't have A 3d printer, you could simply hot Glue the Bottom of the Prism to the top of the motor shaft.
Designing the Stepper Motor Enclosure/Base:
- Create a simple box or base in Tinkercad. This will house your stepper motor and Arduino, making your project look neat and protecting the electronics.
- Be sure to include cutouts or openings for the stepper motor shaft, the USB cable, and any power wires.
Bringing Your Design to Life (No 3D Printer? No Problem!):
- For 3D Printer Owners: If you have access to a 3D printer, you'll export your finished designs from Tinkercad as .STL files. These files are ready for your 3D printer to build your custom parts!
- No 3D Printer? No Worries! You can still use your Tinkercad design as a blueprint. I also made the prototype out of some left over styrine, but cutting the shape from cardboard works well. Don't forget A bar of Soap box can serve the same purpose.
Wiring It Up! (Connecting the Brains and Brawn)





- Clear Wiring Diagram: Provide a very clear, color-coded wiring diagram. This is crucial for middle schoolers.
- Step-by-Step Instructions:
- Connect the Stepper Motor Driver to the Arduino:
- IN1 to Arduino Digital Pin 8
- IN2 to Arduino Digital Pin 9
- IN3 to Arduino Digital Pin 10
- IN4 to Arduino Digital Pin 11
- VCC to Arduino 5V
- GND to Arduino GND
- Connect the Stepper Motor to the Driver Board: (Usually a plug-and-play connection).
- Powering the Arduino: Connect the Arduino to your computer via USB.
- Safety Tip: Always double-check your wiring before plugging in the Arduino!
Bringing It to Life With Arduino Code! (The Magic Spell)

Upload the code to your Arduino, They have a wonderful site to help you if you're not sure how to do this step:
https://support.arduino.cc/hc/en-us/articles/4733418441116-Upload-a-sketch-in-Arduino-IDE
Our simple sketch will cause the motor to move back and forth at random.
Code Explanation (line by line or in chunks):
- #include <Stepper.h>: Explains, including the library.
- stepsPerRevolution: Explain what this value means and why it's important (how many tiny steps make one full circle).
- myStepper(stepsPerRevolution, ...): Explains initializing the stepper motor object.
- myStepper.setSpeed(): how to control the rotation speed.
- myStepper.step(): how to make the motor move a certain number of steps.
- delay(): pausing the program.
Downloads
Assembling Your Rainbow Refraction Machine!


- Step-by-step assembly instructions:
- Mount the stepper motor to your Tinkercad-designed base (or cardboard base) using glue.
- Attach the prism holder to the stepper motor shaft.
- Secure the prism into its holder.
- Carefully place your Arduino inside the enclosure, ensuring wires aren't stressed.
- Adjust the external LED, so its light shines directly onto the prism, move it around a bit to find the best positioning.
- Make sure everything is stable and secure.
Light Up Your World! (Testing and Experimenting)


- Testing: Plug in your Arduino. The stepper motor should begin to rotate, and if light is shining on your prism, you should start seeing colors!
- Experimentation:
- Light Source: Try different light sources (natural sunlight, flashlight, phone flashlight) to see how the intensity and type of light affect the rainbow.
- Prism Angle: Gently adjust the angle of your prism to get the best refraction effect.
- Room Lighting: Try it in a dark room vs. a dimly lit room.
- Speed: Change the myStepper.setSpeed() value in your code and re-upload to see how it changes the rotation.
- Steps: Adjust the myStepper.step() values to make the prism rotate by smaller or larger amounts.
- Troubleshooting Tips:
- Motor not turning? Check wiring, power, and stepsPerRevolution value.
- No rainbow? Ensure enough light is hitting the prism and that the prism is clear.
Beyond the Rainbow!




- Recap: You've successfully built an Arduino-powered light refraction machine! You've explored the magic of light, understood how white light is made of many colors, and learned about Sir Isaac Newton's amazing discoveries.
- Further Exploration/Challenges:
- Can you add a push button to start/stop the motor?
- Can you add an LED that changes color based on the light diffused?
- Design a more elaborate enclosure for your project.
- Research other ways light can be manipulated (diffraction, reflection).
Let me know if this build works for you!
Share your stunning and colorful creations in the comments below! I can't wait to see your unique rainbow displays!