Project tutorial

Arduino Sunflower

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

  • 11,965 views
  • 19 comments
  • 51 respects

Components and supplies

About this project

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

Schematics

Solar Tracker Circuit Diagram
solar_tracker_tftE0iQPO7.fzz
Sunflower Schematics
Sunflower schematics phlicvweht

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);
}

Comments

Similar projects you might like

Magic Lamp

by Nekhil ravi

  • 1,162 views
  • 3 comments
  • 12 respects

PuzzleBox

Project tutorial by Arduino

  • 445 views
  • 0 comments
  • 4 respects

Arduino MKR GSM 1400 and DTMF

by Arduino_Genuino

  • 4,234 views
  • 0 comments
  • 9 respects

Love You Pillow

Project tutorial by Arduino

  • 2,883 views
  • 0 comments
  • 5 respects

Arduino Yun Controller

Project showcase by TATCO Inc

  • 258 views
  • 0 comments
  • 3 respects
Add projectSign up / Login