TechnoFabrique
Published © GPL3+

Solar Tracker

The project was to create a little solar tracker, that follows a light. This device can be linked to a robot, a parabola, etc.

IntermediateShowcase (no instructions)1,806
Solar Tracker

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
9V battery (generic)
9V battery (generic)
×1
Photo resistor
Photo resistor
×3
Resistor 10k ohm
Resistor 10k ohm
×3
SG90 Micro-servo motor
SG90 Micro-servo motor
×2

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Schematics

Solar Tracker fritzing

Picture of the fritzing schematic

Code

CODE Solar tracker

C#
// 29/07/2017 - Programme C - Tracker solaire -  Carte Arduino ( UNO ) 
// Ce programme a pour objectif de : 
//                                     -  Traiter les informations apportés par les photorésistances
//                                     -  Gérer la rotation et l'inclinaison du module pour suivre une source lumineuse
// Programme réalisé par Techno_Fabrik

//********************BIBLIOTHEQUES****************************
 // bibliothèque permettant d'utiliser les commandes pour servomoteurs facilement
 #include <Servo.h>
//********************DECLARATIONS****************************

float photo_r_0,photo_r_1,photo_r_2; // valeur des photorésisances
int servo1=6; // commande du premier servo
int servo2=7;
int angle_rot=90,angle_inc=90; // angle des servos
Servo moteur_rotation; 
Servo moteur_inclinaison;

 //*************************INITIALISATION **********************

void setup() {
  
 moteur_rotation.attach(servo1);   // on relie l'obtet au pin de commande
 moteur_inclinaison.attach(servo2);// on relie l'objet au pin de commande
  Serial.begin(9600); 
  delay(2000);
}

//*************************************** BOUCLE ***************************

void loop() {
 
while ( (angle_rot > 10 )&&(angle_rot< 170) && (angle_inc>10)&&(angle_inc<170)) // sécurité pour les servos
{
photo_r_0=analogRead(A0);Serial.print("R_0 :   ");Serial.println(photo_r_0); // entrée analogique 8 bits = 1024 valeurs = 0 à 5V
photo_r_1=analogRead(A1);Serial.print("R_1 :   ");Serial.println(photo_r_1);
photo_r_2=analogRead(A2);Serial.print("R_2 :   ");Serial.println(photo_r_2);

   
if ( photo_r_0<photo_r_1-3)  // selon la valeur des photorésistances, on va moduler l'angle des servomoteurs
{
  angle_rot=angle_rot-1;
  moteur_rotation.write(angle_rot);
}
else if (photo_r_0>photo_r_1+3)
{
  angle_rot=angle_rot+1;
  moteur_rotation.write(angle_rot);
}

if (photo_r_2>photo_r_1+3)
{
  angle_inc=angle_inc-1;
  moteur_inclinaison.write(angle_inc);
}
else if (photo_r_2<photo_r_1-3)
{
  angle_inc=angle_inc+1;
  moteur_inclinaison.write(angle_inc);
}
}
Serial.println(" ANGLE SERVO MAXIMUM ");
}

Credits

TechnoFabrique
3 projects • 0 followers
Student - Engineering School

Comments