Project tutorial
Arduino Sunflower

Arduino Sunflower

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

  • 32,122 views
  • 34 comments
  • 92 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

Valentine's Sunflower

Project tutorial by circuito.io team

  • 6,910 views
  • 11 comments
  • 22 respects

Solar Panel Sun Tracker - Phone Charger

Project tutorial by FIELDING

  • 27,297 views
  • 11 comments
  • 118 respects

Robotic Arm from Recycled Materials

Project tutorial by circuito.io team

  • 24,659 views
  • 22 comments
  • 97 respects

Pathfinder

Project showcase by Team Maverick

  • 23,799 views
  • 15 comments
  • 121 respects

Home Automation Using Raspberry Pi 2 And Windows 10 IoT

Project tutorial by Anurag S. Vasanwala

  • 297,272 views
  • 98 comments
  • 706 respects

Windows Remote Arduino

Project tutorial by Team Windows IoT

  • 166,224 views
  • 167 comments
  • 339 respects
Add projectSign up / Login