Introduction: Create an Arduino Controlled Light-Following Flower Bot
In this Arduino-based project, you will create a "biomimetic," or biology-inspired, flower that follows a light source. You have probably seen this behavior in your houseplants! Plants require sunlight to grow and thrive, and "heliotropic" or light-tracking flowers turn to face the sun throughout the day so they absorb as much light as possible. This process has inspired a lot of biomimetic technology. Some solar panel arrays use a sun tracking system so the panels always face the direct sunlight during the day!
In this project, when you put your flower in a window (or a shine a flashlight on it) the project compares the values of two light sensors to figure out where the light is, then turns a servo motor to rotate the flower.
You can use a plastic or ceramic flower pot for this project, but we used a clear mason jar so you can see the Arduino and breadboard stuffed inside. Whether you create your own colorful tissue paper flower, or get a plastic flower from the craft store, this Flower Bot will be a welcome friend for your window sill garden! We named ours Seed-3PO.
Electronic supplies needed:
- Arduino UNO (or a smaller board)
- Small breadboard (14x30 sockets or smaller)
- Small servo motor
- 2x photoresistors
- 2x 1000 ohm resistors
- 100 uF capacitor
- Jumper wires
- 9V battery and barrel jack adapter
- 4x flexible wires (~5 inches)
- Arduino IDE
- Arduino code provided
Craft/construction materials needed:
- Flower pot (we're using a mason jar!)
- Fake flower (optional)
- Colored tissue paper
- Pipe cleaner
- Thin cardboard or card stock
- Duct Tape or Scotch Tape
Some other useful tools:
- Soldering iron
- Wire stripper
- Shrink tubing
Step 1: Program the Arduino
This project uses the Arduino UNO, but it can be adapted for a different board as long as you have two Analog Inputs and one Digital Output available. Start by downloading the Arduino code file, and upload the code to your board.
Here's a 123D Circuits project, illustrating how the light following flower works. You can press "Start Simulation" to try it out. Try highlighting the two photo sensors and sliding the light level bars back and forth. You will see the servo motor moving! The servo will point towards the side of the flower that has MORE light shining on it. If both sides are capturing the same amount of light, that represents a room with uniform lighting -- the servo will point in the center. Try it out!
Step 2: Extend the Photo Sensors
Since we need the two-pin light sensor components to stick up above the edge of the flower pot (or mason jar), we will extend the leads by soldering long wires to the tips. Our wires ended up being 5 inches long.
- Strip the ends of four wires to expose a length that you are comfortable soldering.
- Solder one wire to each of the photosensor leads.
- It's a good idea to cover the solder joints with shrink tubing if you have it available! Slide the tubing over the solder joint and use a heat gun or a warm (not hot) area of your soldering iron to shrink it to the wire.
Step 3: Make a Cover for the Fower Pot
In this step you are going to create a card stock cover for the flowerpot. The servo motor and photo sensors will be mounted from below and their active parts (the sensors, and the rotating head) will poke out the top.
- Trace the outline of your container and cut it out.
- Measure a section of the servo motor that will stick up above the lid and sketch that shape in the center of the card stock. Trim it out with scissors or an X-acto knife. It's ok if the hole is a little too big.
- Cut two round holes to either side of the motor hole, and in front. They should be big enough for the photo resistors to poke up from below. It might be easiest to use a hole-punch for this part!
- After the holes are cut, insert the servo into its slot from below, and secure with tape.
- Finally, try fitting the card stock + motor onto the top of your pot. We actually went ahead and secured the card stock with the mason jar ring to make sure it was a good fit! In your project, you might simply tape around the edge of the lid using colored Duct Tape or clear Scotch Tape.
Step 4: Build the Paper Flower
In this step you will create a colorful paper carnation! We found a wonderful Instructable by KatieKay showing us how it's done. We modified our flower using 12 3x3" squares of tissue paper:
- 2 sheets yellow
- 3 sheets lilac
- 4 sheets purple
You can create whatever color combinations you want. This part doesn't need to be inspired by nature!
As a final step, trim the pipe cleaner to whatever flower height you like, and secure it to the plastic arm that comes with your servo motor by wrapping it around a few times.
Step 5: Assemble the Circuit
Assemble the breadboard circuit using the circuit simulator as a guide. Here are a few tips to keep in mind:
- The servo motor has three wires that need to be connected correctly. The power line (usually red) connects to 5V; the ground line (usually black) connects to ground; the signal line (white or yellow) connects to pin 9 on the Arduino.
- If you are using an electrolytic capacitor across the servo, make sure it is oriented correctly! The side marked with a minus sign or line will be connected to the black ground line of the servo.
- Make sure the jumpers connecting the breadboard and Arduino are long enough. You might have to bend or wrap these later when you stuff both boards into the flower pot.
Step 6: Calibrate the Flower Bot
To get the maximum amount of motion out of your Flower Bot, you'll need to calibrate its sensors for the lights in your room. You'll do this calibration in Arduino IDE using the serial monitor.
- First, figure out what your lighting conditions are. Is your light source a lamp, flashlight, or light from the window? Position your circuit so that the right-hand sensor gets the highest intensity light that it can, and the left side falls in a shadow.
- Open the serial monitor in Arduino IDE. While it's running, read the sensorDiff value. Input this value in the map() function. In our example, we read a value of approximately 685 and replaced the original value (500) with this.
- Repeat the process by casting your light source on the left side, and leaving the right side in a shadow. Adjust the map() function accordingly; one number should be positive and the other negative.
- After changing the map() function to fit your room's lighting conditions, upload the code to your Arduino again, and shine light on the photo sensors to see what happens now!
Note: it might be helpful to mount your paper flower to the servo motor during this step.
Step 7: Troubleshooting
It can be hard to keep track of which sensor is which, and which way your flower bot is supposed to rotate. That's ok! If at any point it seems like the flower is rotating the opposite way that is should be, there are a few things that you can try:
- On the Arduino, trade the wires that are connected to analog inputs A0 and A1
- At the top of your robotic flower, swap the positions of the light sensors (the long wires should be bendable)
- Open up Arduino IDE and switch the A0 and A1 pin assignments
Step 8: Stuff the Flower Pot
Before stuffing the electronics into your flower pot (or jar) it is a good idea to tape over any connections that might come loose! You can also arrange the breadboard and Arduino in a convenient way - for us, it was helpful to tape them back-to-back.
- Tape down any wire connections that might come loose.
- Plug in the 9V battery barrel jack.
- Place the breadboard and Arduino in the container, making sure that the photo sensors, servo motor, and card stock lid are sticking out of the top. You might need to stuff some tissue paper or crumpled card stock in the bottom to lift the electronics towards the lid. We thought our Flower Bot could use some shiny gold tissue paper.
- Thread the photo sensors through the small holes in the card stock.
- Secure the lid by taping around the rim. For our version, we just used the handy ring that comes with with mason jar.
Step 9: Complete the Flower Bot
Once all of the electronic components and the card stock lid are secure, you can add the flower! Simply press the servo motor arm into place. You might have to try this a couple times to make sure the flower is pointing the right way.
As a finishing touch, you can camouflage the photo sensors with paper leaves!
Congratulations on finishing your light-following Flower Bot! Now you can play with your flower using a flashlight, or put it on a window sill and see it move with the sun throughout the day!
Step 10: Bonus: Circuit Scribe Variation
Our original prototype of the light following flower bot was created with the Circuit Scribe Maker Kit components. We used two of the 3-terminal light sensor modules instead of the photo sensors and 1 k-ohm resistors.
Materials needed (in addition to original materials):
- Circuit Scribe pen
- Steel sheet or other magnetic surface
- Circuit Stencil or paper circuit template (provided below)
- Card stock
- 2x light sensor modules
- 4x Arduino connection cables
- Program the Arduino UNO the same way that you would for the breadboard version of the project.
- Print out a Circuit Scribe template from the 123D Circuits example below and trace it with Circuit Scribe ink, or draw the pattern free-hand using your Circuit Stencil as a guide for module foot spacing.
- Place the paper circuit on the Steel Sheet from the Circuit Scribe kit, or on another magnetic surface.
- Place the two light sensors, as shown.
- Tape the servo motor + paper flower in between the two light sensor modules.
- Finally, break out the A1, GND, +5V, and A0 pins on the Arduino (in that order) using the magnetic connection cables, and connect the magnets to the paper circuit.
Once everything is constructed, you can go through the same sensor calibration and troubleshooting steps (Steps 7 & 8) that you used for the breadboard version of the circuit!
Have fun with your robotic flowers! Did you create this project, or prototype something similar using Circuit Scribe? Leave comments below!