Introduction: Valentine's Sunflower
With Valentine’s Day coming up, we started looking for project ideas with a romantic twist. While searching for ideas around us our eyes fell on a plastic sunflower that we had on our office window. Truth be told, it was quite ugly, but it gave us an idea - what if we made a flower that moves according to light, just like a real sunflower. After a few revisions (and a bunch of filament) we give youthis Valentine's Sunflower! Spread the love.
Step 1: The Electronics
If you’ve been following our tutorials, you should already know the drill:
1. Click on this magic link to circuito.io with the exact components you need for this project.
2. Make adjustments if needed. For example, if you want to use a battery instead of the wall adapter or if you have a different type of Arduino. We used a pro-mini for this project. If you want to use a different one, make sure that it fits in the flower.
3. Click Generate (the red button at the bottom of the builder).
Step 2: Make Sure You Have All the Components
Check that you have all the parts you need, including the peripherals - resistors, cables, jumper wires etc. The list will appear in the first step of the Step-by-Step guide.
You can click on the different parts on the list (on the app) and you’ll be redirected to a website where you can purchase them if needed.
Step 3: Wiring
Scroll down a bit in the reply you got, and you’ll see a step-by-step guide that will navigate you through the wiring of your circuit.
Step 4: Code
In the code section on circuito.io, you'll see an example code that integrates all the components used in the project.
1. Download the code from circuito.io
2. Unzip\extract it to your computer
3. Upload it to your Arduino IDE (which you can download here)
4. Replace the firmware.ino code with the code at the end of this tutorial.
5. Copy the new code below and paste it into the firmware.ino tab. This code is specific for the Valentine's Sunflower project.
#include "Global.h" int pos = 10; //Starting position /* This code sets up the essentials for your circuit to work. It runs first every time your circuit is powered with electricity. */ void setup() { // Setup Serial which is useful for debugging // Use the Serial Monitor to view printed messages Serial.begin(9600); Serial.println("start"); servo.attach(SERVO_PIN); servo.write(pos); } /* This code is the main logic of your circuit. It defines the interaction between the components you selected. After setup, it runs over and over again, in an eternal loop. */ void loop() { // Get current light reading, substract the ambient value to detect light changes int ldrSample = ldr.readAverage(1000); Serial.print(ldrSample); Serial.print('\t'); pos = map(ldrSample,200,900,10,95); pos = constrain(pos, 10,95); Serial.println(pos); servo.write(pos); delay(1000*20); }
Step 5: Making the Flower
Step 6: Assembly
- For the petals, the bar and the sepal we used a thin flexible steel wire. There are small drills built in to the design exactly for this.
- The servo motor is connected with 2 small screws to the side of the base and with a nail to the sepal.
- Place the Mini photocell in the dedicated drill in the base, underneath the servo pedestal.
Step 7: That's It!
Once everything is built and ready, you can start testing your flower and making tweaks and changes to the code if needed. Here's one of the tests we did to check the movement of the servo in reaction to light changes.
Have a Sunny Valentine's Day :)