Arduino Solar Tracker by geo bruce Download 5 Steps
+ Collection Favorite
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 // 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
About This Instructable
66,855 views
Posted: Jul 3, 2011
170 favorites
License:
geo bruce Follow
101
Bio: 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 »
More by geo bruce
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
int avr = (rt + rd) / 2; // average value right int dvert = avt - avd; // check the diffirence of up and down int dhoriz = avl - avr;// check the diffirence og left and rigt
Related 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 horizontal angle { 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); }
light detection + data logging white arduino by DKN
DIY Arduino PIR Motion Sensor Lighting & Security by sspence
See More
Arduino Solar Tracker
Remove these ads by Signing Up
View All Steps Next »
« Previous
Post Comment
Yasesu says:
Dec 14, 2012. 9:11 AM
Reply
Dec 14, 2012. 9:22 AM
Reply
Dec 14, 2012. 11:59 AM
Reply
Could you add a parts list to the instructions? Thanks
geo bruce (author) in reply to Yasesu done ;) 5
Yasesu in reply to geo bruce
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 to take your idea, and make it bigger. I need to find some large servo motors.
geo bruce (author) in reply to Yasesu
Dec 14, 2012. 1:30 PM
Reply
Jan 24, 2013. 2:56 AM
Reply
if you want to go big you can better go for stepper motors and change the code a little bit 5
tolstoyan in reply to geo bruce
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 what exactly to replace if any, thanks because im planning to build this its just that i bought stepper motor instead of servo
Thank you for interesting in our services. We are a non-profit group that run this website to share documents. We need your help to maintenance this website.