Project tutorial
Arduino Sunflower

Arduino Sunflower

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

  • 68,974 views
  • 48 comments
  • 154 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

Make an Autonomous "Follow Me" Cooler

Project tutorial by Hacker Shack

  • 247,577 views
  • 305 comments
  • 755 respects

Detecting Obstacles and Warning - Arduino and Ultrasonic

Project tutorial by Ammar Atef Ali

  • 186,184 views
  • 54 comments
  • 198 respects

Simple Programmable Robotic Arm

Project showcase by Ryan Chan

  • 165,431 views
  • 110 comments
  • 378 respects

Solar Panel Sun Tracker - Phone Charger

Project tutorial by FIELDING

  • 87,314 views
  • 24 comments
  • 251 respects

Ultrasonic Security System

Project tutorial by Ivan

  • 84,092 views
  • 52 comments
  • 170 respects

Arduino 32x8 LED Matrix Info Display

Project showcase by ericBcreator

  • 79,403 views
  • 84 comments
  • 116 respects
Add projectSign up / Login