Skip to content

MANE 3351 - Manufacturing Engineering Analysis

Laboratory Four Assignment

Assigned: September 25, 2024

Due: October 2, 2024 before 2:00 pm


Incorporate two LDRs and a servo to mimic a solar tracking system. This assignment was inspired by Building your own Sun Tracking Solar Panel using an Arduino website.


Equipment Needed

The following items are required to complete the fourth laboratory assignment. Note that this is the total equipment required for lab four; you already have many of the items from completing the first three labs.

  • 1 Arduino Uno
  • 1 USB printer cable
  • 1 breadboard
  • 1 servo
  • 9 male-to male (mm) jumper cable
  • 2 light detecting resistors (LDRs)
  • 2 10KΩ resistor

Assignment

Step One

Construct the circuit shown below on a breadboard. Do not connect to the Arduino Uno until after the sketch is uploaded.

schematic

Step Two

Open the Arduino IDE and enter the code for the sketch shown below. Verify the code and upload to your Arduino Uno. Do not forget to add documentation to the top of the program code.

#include <Servo.h>

Servo servo ;

int eastLDR = 0;

int westLDR = 1;

int east = 0;

int west = 0;

int error = 0;

int calibration = 0;

int servoposition = 90;

void setup()

{
  Serial.begin(9600);
  servo.attach(10);

}

void loop()

{

  east = calibration + analogRead(eastLDR);

  west = analogRead(westLDR);

  Serial.print("East= "); Serial.println(east);
  Serial.print("West= "); Serial.println(west);
  Serial.print("Servo Position="); Serial.println(servoposition);

  if (east < 350 && west < 350)

  {

    while (servoposition <= 150)

    {

      servoposition++;

      servo.write(servoposition);

      delay(100);

    }

  }

  error = east - west;

  if (error > 15)

  {

    if (servoposition <= 150)

    {

      servoposition++;

      servo.write(servoposition);

    }

  }

  else if (error < -15)

  {

    if (servoposition > 20)

    {

      servoposition--;

      servo.write(servoposition);

    }

  }

  delay(500);

}

Step Three

Connect your breadboard to the Arduino and ensure that the program is working properly.

Step Four

Save and run the Python program. Hopefully, there will be no errors in the circuit and code and it will run immediately. Debug the schematic and code until everything works. Meet with Dr. Timmer in his office before the deadline (September 9, 2024 at 2:00pm) and demonstrate your working laboratory one project.


Hints

The servo contains three wires and will accept male jumpers. Please ensure that the following connections are made:

  • Servo brown wire to ground
  • Servo red wire to +5V
  • Servo orange wire to signal (D10)