Skip to main content

How To Make A Solar Tracker Using Arduino ?

Hello guys,In this post we will tell you how you can create your  Solar Tracker project using arduino.
Circuit diagram and source code is given below.
Subscribe our blog so that you can't miss any update from us.
Note- Please Check The Code And Do All Thing As Written There.

Material required-
1-Arduino Development Board
2-Some LDR
3-Servo motor
4-Solar panel
5-Jumper wires

Circuit Diagram-
Source Code-

#include <Servo.h>
//defining Servos
Servo servohori;
int servoh = 0;
int servohLimitHigh = 160;
int servohLimitLow = 20;
Servo servoverti;
int servov = 0;
int servovLimitHigh = 160;
int servovLimitLow = 20;
//Assigning LDRs
int ldrtopl = 2; //top left LDR green
int ldrtopr = 1; //top right LDR yellow
int ldrbotl = 3; // bottom left LDR blue
int ldrbotr = 0; // bottom right LDR orange
void setup ()
{
servohori.attach(10);
servohori.write(0);
servoverti.attach(9);
servoverti.write(0);
delay(500);
}
void loop()
{
servoh = servohori.read();
servov = servoverti.read();
//capturing analog values of each LDR
int topl = analogRead(ldrtopl);
int topr = analogRead(ldrtopr);
int botl = analogRead(ldrbotl);
int botr = analogRead(ldrbotr);
// calculating average
int avgtop = (topl + topr) / 2; //average of top LDRs
int avgbot = (botl + botr) / 2; //average of bottom LDRs
int avgleft = (topl + botl) / 2; //average of left LDRs
int avgright = (topr + botr) / 2; //average of right LDRs
if (avgtop < avgbot)
{
servoverti.write(servov +1);
if (servov > servovLimitHigh)
{
servov = servovLimitHigh;
}
delay(10);
}
else if (avgbot < avgtop)
{
servoverti.write(servov -1);
if (servov < servovLimitLow)
{
servov = servovLimitLow;
}
delay(10);
}
else
{
servoverti.write(servov);
}
if (avgleft > avgright)
{
servohori.write(servoh +1);
if (servoh > servohLimitHigh)
{
servoh = servohLimitHigh;
}
delay(10);
}
else if (avgright > avgleft)
{
servohori.write(servoh -1);
if (servoh < servohLimitLow)
{
servoh = servohLimitLow;
}
delay(10);
}
else
{
servohori.write(servoh);
}
delay(50);
}

Comments

Popular posts from this blog

Controlling A Servo Motor Using MPU 6050 Sensor .

Hello guys, In this post we are going to tell you that how you can control servo motor using MPU Sensor. Please subscribe to our blog, so that you can't miss any update from us.Join us @Microelectronics. Code and circuit diagram is given post. Material required- 1-MPU Sensor 2-An Arduino 3-Servo motor  4-Some jumper wires Circuit diagram- Source code- // I2Cdev and MPU6050 must be installed as libraries, or else the .cpp/.h files // for both classes must be in the include path of your project #include "I2Cdev.h" #include "MPU6050_6Axis_MotionApps20.h" //#include "MPU6050.h" // not necessary if using MotionApps include file // Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation // is used in I2Cdev.h #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE     #include "Wire.h" #endif #include <Servo.h> Servo myservo;  // create servo object to control a servo   // class default I2C address is 0x...

How to make smartphone control robot car using Nodemcu

  Hey, In today's blog we are going to build a robot car using Nodemcu. REQUIRED STUFF: Nodemcu Bluetooth module Motor driver ic BO motor BO motor wheel Chassis 3.7 v battery SCHEMATIC:   CODE IT: Making electronics is too pretty simple with Us. Join and Make with Us.

How To Make A Real Time GPS Location Tracker Using NodeMcu ?

Hello Guys , Welcome Back To Another Post From Microelectronics , In This Post We Will Learn That How To Make A Real Time GPS Location Tracker Using NodeMcu Module. For Further Details You Can Aks Your Question In Message Bar. Material Required - Nodemcu ESP8266 Ublox NEO 6M GPS Jumpers Connections:-  VCC  -  3.3V GND  -  GND RX  -  D1 TX  -  D2 Code - #include <TinyGPS++.h> #include <SoftwareSerial.h> #define BLYNK_PRINT Serial #include <ESP8266WiFi.h> #include <BlynkSimpleEsp8266.h> static const int RXPin = 4, TXPin = 5;   // GPIO 4=D2(conneect Tx of GPS) and GPIO 5=D1(Connect Rx of GPS static const uint32_t GPSBaud = 9600; //if Baud rate 9600 didn't work in your case then use 4800 TinyGPSPlus gps; // The TinyGPS++ object WidgetMap myMap(V0);  // V0 for virtual pin of Map Widget SoftwareSerial ss(RXPin, TXPin);  // The serial connection to the GPS device BlynkTimer timer; f...