Project tutorial

Arduino Sunflower

The sunflower follows the light using a servo motor and two photoresistors.

  • 20,433 views
  • 24 comments
  • 69 respects

Components and supplies

About this project

The sunflower follows the light using a servo motor and two photoresistors.

Code

Solar Tracker CodeC/C++
#include <Servo.h>

int sensorPin = A0;
int servoPin  = 9;

int sensorValue = 0;
int servoGrad = 90;
int tolerance = 40;

Servo myservo;

void setup() {
  pinMode( sensorPin, INPUT);
  myservo.attach( servoPin );
  myservo.write( servoGrad );
}

void loop() {
  sensorValue = analogRead(sensorPin);
  if ( sensorValue < (512-tolerance) )
  {
    if (servoGrad < 180) servoGrad++;
  }

  if ( sensorValue > (512+tolerance) )
  {
    if (servoGrad > 0) servoGrad--;
  }

  myservo.write( servoGrad ); 

  delay(100);
}

Schematics

Sunflower Schematics
Schermata 2018 03 03 alle 21 57 54 arqht6xwyl

Comments

Similar projects you might like

A Microwave Interface for the IKEA Duktig Kids Kitchen

Project showcase by Myles Eftos

  • 1,900 views
  • 9 comments
  • 10 respects

Arduino Automated Parking Garage

Project tutorial by ashraf_minhaj

  • 555 views
  • 5 comments
  • 7 respects

Servo Signals and Characterization

by 3 developers

  • 1,744 views
  • 4 comments
  • 15 respects

Music Adaptive RGB LED with Arduino and Processing

Project in progress by ounane mohamed elfarouk

  • 1,199 views
  • 6 comments
  • 13 respects

Cellular IoT with Blynk & Hologram

by Moheeb Zara

  • 5,458 views
  • 9 comments
  • 19 respects

Monitoring Temperature Remotely with Blynk for Dummies

Project in progress by Cmtelesann

  • 1,456 views
  • 2 comments
  • 5 respects
Add projectSign up / Login