4
Arduino Solar Tracker http://www.instructables.com/id/Arduino-Solar-Tracker/step5/The-Code/[25-Sep-2013 1:20:26 AM] Step 5: The Code you can download the code down this page /* this code is written by geobruce for more info check my site http://xprobe.net */ #include <Servo.h> // include Servo library Servo horizontal; // horizontal servo int servoh = 90; // stand horizontal servo Servo vertical; // vertical servo int servov = 90; // stand vertical servo // LDR pin connections // name = analogpin; int ldrlt = 0; //LDR top left int ldrrt = 1; //LDR top rigt int ldrld = 2; //LDR down left int ldrrd = 3; //ldr down rigt void setup() { Serial.begin(9600); // servo connections // name.attacht(pin); horizontal.attach(9); vertical.attach(10); } void loop() { int lt = analogRead(ldrlt); // top left int rt = analogRead(ldrrt); // top right int ld = analogRead(ldrld); // down left int rd = analogRead(ldrrd); // down rigt int dtime = analogRead(4)/20; // read potentiometers int tol = analogRead(5)/4; int avt = (lt + rt) / 2; // average value top int avd = (ld + rd) / 2; // average value down int avl = (lt + ld) / 2; // average value left About This Instructable Posted: Jul 3, 2011 License: 66,855 views 170 favorites Hello, I'm Bruce. I'm a student at Don Bosco Hoboken in Belgium. I have a wide variety of interests: electronics, computers, technology, ... In my spare time I spend a lot of time on: projects, explor... read more » geo bruce Follow 101 Bio: More by geo bruce Arduino Solar light servo cool energy Tags: Arduino Solar Tracker by geo bruce Download 5 Steps + Collection Favorite let's make share what you make > Explore Create Contests Community Sign Up Log In Login

Arduino Solar Tracker

Embed Size (px)

DESCRIPTION

TRACKER IN ARDUINO

Citation preview

Page 1: Arduino Solar Tracker

Arduino Solar Tracker

http://www.instructables.com/id/Arduino-Solar-Tracker/step5/The-Code/[25-Sep-2013 1:20:26 AM]

Step 5: The Codeyou can download the code down this page

/* this code is written by geobrucefor more info check my site http://xprobe.net*/#include <Servo.h> // include Servo library

Servo horizontal; // horizontal servoint servoh = 90; // stand horizontal servo

Servo vertical; // vertical servo int servov = 90; // stand vertical servo

// LDR pin connections// name = analogpin;int ldrlt = 0; //LDR top leftint ldrrt = 1; //LDR top rigtint ldrld = 2; //LDR down leftint ldrrd = 3; //ldr down rigt

void setup(){ Serial.begin(9600);// servo connections// name.attacht(pin); horizontal.attach(9); vertical.attach(10);}

void loop() { int lt = analogRead(ldrlt); // top left int rt = analogRead(ldrrt); // top right int ld = analogRead(ldrld); // down left int rd = analogRead(ldrrd); // down rigt

int dtime = analogRead(4)/20; // read potentiometersint tol = analogRead(5)/4;

int avt = (lt + rt) / 2; // average value topint avd = (ld + rd) / 2; // average value downint avl = (lt + ld) / 2; // average value left

About This Instructable

Posted:Jul 3, 2011

License:

66,855 views

170 favorites

Hello, I'm Bruce. I'm a student at DonBosco Hoboken in Belgium. I have a widevariety of interests: electronics, computers,technology, ... In my spare time I spend a lotof time on: projects, explor...read more »

geo bruce Follow 101

Bio:

More by geo bruce

Arduino Solar light servo cool energyTags:

Arduino Solar Tracker by geo bruce

Download5 Steps

+ Collection Favorite

let's make

share what you

make >

Explore Create Contests Community Sign Up

Log In

Login

Page 2: Arduino Solar Tracker

Arduino Solar Tracker

http://www.instructables.com/id/Arduino-Solar-Tracker/step5/The-Code/[25-Sep-2013 1:20:26 AM]

int avr = (rt + rd) / 2; // average value right

int dvert = avt - avd; // check the diffirence of up and downint dhoriz = avl - avr;// check the diffirence og left and rigt

if (-1*tol > dvert || dvert > tol) // check if the diffirence is in the tolerance else change vertical angle{if (avt > avd){servov = ++servov;if (servov > 180){servov = 180;}}else if (avt < avd){servov= --servov;if (servov < 0){servov = 0;}}vertical.write(servov);}

if (-1*tol > dhoriz || dhoriz > tol) // check if the diffirence is in the tolerance else change horizontalangle{if (avl > avr){servoh = --servoh;if (servoh < 0){servoh = 0;}}else if (avl < avr){servoh = ++servoh;if (servoh > 180){servoh = 180;}}else if (avl == avr){// nothing}horizontal.write(servoh);}delay(dtime);}

solar_tracker__english_.pde 1 KB

Related

See More

sun tracking following sensor

Boe Bot/Arduino linefollowing robotby red_green

Arduino Solar TrackingRobotby Bot1398

Arduino 2-axis servo solartrackerby aplavins

light detection + data loggingwhite arduinoby DKN

DIY Arduino PIR MotionSensor Lighting & Securityby sspence

Page 3: Arduino Solar Tracker

Arduino Solar Tracker

http://www.instructables.com/id/Arduino-Solar-Tracker/step5/The-Code/[25-Sep-2013 1:20:26 AM]

« Previous Next »View All Steps

Dec 14, 2012. 9:11 AM Reply

Dec 14, 2012. 9:22 AM Reply

5

Dec 14, 2012. 11:59 AM Reply

Dec 14, 2012. 1:30 PM Reply

5

Jan 24, 2013. 2:56 AM Reply

Remove these ads by Signing Up

Yasesu says:

geo bruce (author) in reply to Yasesu

Yasesu in reply to geo bruce

geo bruce (author) in reply to Yasesu

tolstoyan in reply to geo bruce

Could you add a parts list to the instructions?

Thanks

done ;)

Thank you. That is great. I have a 3 panel 45W solar panel from Harbor Freight.I've been looking at ideas to keep the panels facing the sun. Now I just need totake your idea, and make it bigger. I need to find some large servo motors.

if you want to go big you can better go for stepper motors and change the code a little bit

hello geo bruce im a beginner here at the arduino so im not really a code jockey,can you please tell me which part of the code do i have to modified and whatexactly to replace if any, thanks because im planning to build this its just that ibought stepper motor instead of servo

Page 4: Arduino Solar Tracker

Arduino Solar Tracker

http://www.instructables.com/id/Arduino-Solar-Tracker/step5/The-Code/[25-Sep-2013 1:20:26 AM]

Jul 27, 2013. 2:01 AM ReplyRene Artois in reply to tolstoyan

You can't drive stepper motors directly with arduino. It will burn. Use arduinostepper motor shield insted. It can handle bigger loads.

About UsWho We AreAdvertiseContactJobsHelp

Find UsFacebook

Youtube

Twitter

Pinterest

ResourcesFor TeachersArtists in ResidenceForumsAnswers

MobileDownload our new apps foriOS and android!

Android iOS

Visit Our Store »

Go Pro Today »

Join our newsletter:Join!

© Copyright 2013 Autodesk Inc. All rights reserved Terms of service | Privacy | Legal Notices & Trademarks | Mobile Site