View the step-by-step solution to:

In this project, students will design a simple Solar Tracker that would achieve maximum exposure of the Solar Panel to the light by following the sun...

In this project, students will design a simple Solar Tracker that would achieve maximum exposure of the Solar Panel to the light by following the sun from its eastern (morning) position towards its western (evening) position. After sensing the sunset (no exposure to the light) it is supposed to go back to its starting (morning) position and wait for the sunrise. The maximum angle from its horizontal position will be limited to +/- 45. I am able to follow the solar panel with the light source but am not able to stop the panel at a home position and every time it reaches the maximium position of +/-45 it doesn't stop just continue to move to 360 degrees completely . The whole program is based on stepper motor with 1023 steps. I have attached mine code written so far. as well



const int numberOfSteps = 5;

const int pulse = 11;

const int directionPin_1 = 10;

//const int directionPin_2 = 10;

int i = 0;


void setup() {

 pinMode(pulse, OUTPUT);

 pinMode(directionPin_1, OUTPUT);

 // pinMode(directionPin_2, OUTPUT);

 Serial.begin(9600);


}


void loop() {

 int sensorValue_0 = analogRead(A0);

 int sensorValue_1 = analogRead(A1);

 float voltage_0 = sensorValue_0 * (5.0 / 1023.0);

 float voltage_1 = sensorValue_1 * (5.0 / 1023.0);

 float v_diff = voltage_0 - (voltage_1 + 0.30);

 Serial.println(voltage_0);

 Serial.println(voltage_1);

 Serial.println(v_diff);

  

 if (v_diff > 2.20){

  move_CW();

 }

 else if (v_diff < 2.35){

  move_CWW();  

 }

 else if (2.20 < v_diff < 2.35){

  stopMoter();

 }

}

void move_CW(){

 digitalWrite(directionPin_1, HIGH);

 delay(10);

 digitalWrite(directionPin_1, LOW);

 for (int i = 0; i <= numberOfSteps; i++){

  digitalWrite(pulse, HIGH);

  delay(50);

  digitalWrite(pulse, LOW);

  delay(50);

 }

}

void move_CWW(){

 digitalWrite(directionPin_1, LOW);

 delay(10);

 digitalWrite(directionPin_1, HIGH);

 for (int i = 0; i <= numberOfSteps; i++){

  digitalWrite(pulse, HIGH);

  delay(50);

  digitalWrite(pulse, LOW);

  delay(50);

 }

}


void stopMoter (){

 delay(15000);

 digitalWrite(directionPin_1, LOW);

 delay(10);

 digitalWrite(directionPin_1, LOW);

 delay(10);

}

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question