Solar+Panel+Concentrator

Created by Jesse Chand and Kamran Fardanesh
 * __Solar Panel Concentrator -__**



A device that automatically tilts a solar panel towards the sun to operate under constant optimal conditions. This project utilizes the Arduino. The following is the source code for the program:

#include 
 * Source Code**

Servo SERVO_L; Servo SERVO_R;

int lightPin1 = 0; int lightPin2 = 1; int lightPin3 = 2; int lightPin4 = 3;

int l1 = -1; int l2 = -1; int l3 = -1; int l4 = -1;

//int ledPin=13; //define a pin for LED

int pos_l = SERVO_L.read; int pos_r = SERVO_R.read;

void setup <span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;">{ <span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;">SERVO_L.attach(9); //Tilt <span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;">SERVO_R.attach(10); //Pan

<span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;">Serial.begin(9600); //Begin serial communcation

<span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;">//pinMode(ledPin, OUTPUT); <span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;">}

<span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;">void loop <span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;">{ <span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;">pan; <span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;">tilt; <span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;">delay(30); <span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;">}

<span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;">void tilt <span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;">{ <span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;"> //TILT SYSTEM - CONTROL SERVO_L <span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;"> l4 = analogRead(lightPin4); <span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;"> l2 = analogRead(lightPin2);

<span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;"> pos_l = SERVO_L.read; <span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;"> if (abs(l4-l2) > 15) <span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;"> { <span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;"> if (l4 > l2) SERVO_L.write(pos_l-1); <span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;"> if (l2 > l4) SERVO_L.write(pos_l+1); <span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;"> } <span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;">}

<span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;">void pan <span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;">{ <span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;"> //PAN SYSTEM - CONTROL SERVO_R <span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;"> l1 = analogRead(lightPin1); <span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;"> l3 = analogRead(lightPin3); <span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;"> Serial.println(l1-l3);

<span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;"> pos_r = SERVO_R.read; <span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;"> if (abs(l1-l3) > 15) <span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;"> { <span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;"> if (l1 > l3) SERVO_R.write(pos_r-1); <span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;"> if (l3 > l1) SERVO_R.write(pos_r+1); <span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;"> } <span style="font-family: 'Courier New',Courier,monospace; font-size: 90%; line-height: 115%;">} <span style="font-family: 'Adobe Myungjo Std M','serif'; font-size: 19px; line-height: 115%;">
 * Template**