Project tutorial

Arduino Sunflower

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

  • 8,218 views
  • 14 comments
  • 37 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

Windows PC Lock/Unlock Using RFID

Project tutorial by Prasanth K S

  • 6,594 views
  • 6 comments
  • 29 respects

LED Cube

Project tutorial by Praditha Alwis

  • 311 views
  • 0 comments
  • 4 respects

Makers (Cubecon) #1 Infrared Transmit & Infrared Receive

Project in progress by Alpha

  • 119 views
  • 0 comments
  • 3 respects

Lie Detector

Project tutorial by Adaline Baskaran

  • 5,537 views
  • 5 comments
  • 16 respects

Arduino Keyboard

Project in progress by Gabriele Scordamaglia

  • 376 views
  • 2 comments
  • 4 respects
Add projectSign up / Login