Project tutorial
Arduino Sunflower

Arduino Sunflower

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

  • 53,040 views
  • 47 comments
  • 133 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

Pathfinder

Project showcase by Team Maverick

  • 39,291 views
  • 22 comments
  • 165 respects

Valentine's Sunflower

Project tutorial by circuito.io team

  • 11,133 views
  • 15 comments
  • 38 respects

Home Automation Using Raspberry Pi 2 And Windows 10 IoT

Project tutorial by Anurag S. Vasanwala

  • 326,588 views
  • 101 comments
  • 786 respects

Make an Autonomous "Follow Me" Cooler

Project tutorial by Hacker Shack

  • 161,440 views
  • 238 comments
  • 545 respects

Arduino 32x8 LED Matrix Info Display

Project showcase by ericBcreator

  • 49,709 views
  • 82 comments
  • 84 respects

UltrasonicEyes

Project tutorial by Unexpected Maker

  • 24,267 views
  • 55 comments
  • 149 respects
Add projectSign up / Login