Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
circuito.io team
Published © GPL3+

Valentine's Sunflower

A romantic project for Valentine's Day - a 3D printed sunflower that opens and closes in reaction to light. Have a Sunny Valentine!

IntermediateFull instructions provided8 hours19,810

Things used in this project

Hardware components

Arduino Pro Mini 328 - 5V/16MHz
SparkFun Arduino Pro Mini 328 - 5V/16MHz
×1
SparkFun Mini photocell
×1
SparkFun Servo - Generic Metal Gear
×1

Software apps and online services

circuito.io
circuito.io
Arduino IDE
Arduino IDE

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Custom parts and enclosures

Sunflower bar

Sunflower - Petal

Sunflower - base

Sunflower - Sepal

Sunflower - grass

Sunflower - tie

Code

Sunny Valentine

Arduino
1. Download the code from circuito.io
2. Open it with Arduino IDE
3. Replace the void setup () from the originial code, with the code presented below
/* 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_SIG);
    servo.write(servoRestPosition);
}

/* 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
    ldrSample = ldr.readAverage(1000);
    Serial.print(ldrSample);
    Serial.print('\t');
    servoRestPosition = map(ldrSample,200,900,10,95);
    servoRestPosition = constrain(servoRestPosition, 10,95);
    Serial.println(servoRestPosition);
    servo.write(servoRestPosition); 
    delay(1000*20);  
}

Credits

circuito.io team

circuito.io team

29 projects • 601 followers
Circuito.io is an online platform that generates wiring and code for Arduino projects. Want to know more? Visit http://circuito.io

Comments