Introduction: Planet Moving Solar System

Paste this link: https://youtube.com/shorts/cbI7iLCaV2M?feature=share into your browser for a video demonstration. This circuit is a solar system, in which the planets move! I will teach you how to make it so 2 planets move, however you can do as many as you want, just repeat the process!

So how does this work might be your question, This was possible with the help of LDR also known as light light-dependent resistor. The arduino board processes the light that falls on the LDR and sends signals to the servo to move in that particular direction.

Since the servo is able to move 180degress each LDR is placed in the opposite direction so that the exposure to the light could be more.

I have given the complete details of building this project, also there is a working video given at the end of this project.

Try building this project since it gives you a hands-on experience in building such creative robots and helps you learn coding.The circuit itself is easy to make, it is more code based!

Supplies

Servo Motors- 2 of them. $15 on Amazon

LDR- 4 of them. $10 on Amazon

Bread Board- 1 $17 on Amazon

Wires - $13 on Amazon

Arduino and cable- $37 on Amazon

Styrofoam/Pompoms/ any ball shaped item for the Planets

Cardboard cover of the board to hide circuit and allow a base for the servos- decorate as you wish

Step 1: Circuit Diagram

This is the circuit I made with Tinkercad Circuits and before building the actual project I tested the circuit with simulation.

This is a smart way to save your costs and time that might sometimes occur due to improper circuits, In my case, everything was tested with simulation with the circuit and codes, and then I started to build the actual project.

Make sure your power jumper wires are in the same area, as if it were anywhere else, it could potentially stop the power to the servo motor.

The Red wires mean power, and the black are ground. The jumper wire connecting the LDR allows the LDR's to be one entity, and attached to one pin, such as the A0 PIN and A1 pin. This code works as is:

  • Include Servo Library:
cpp

#include <Servo.h>

This line includes the Servo library, which is required to control servo motors.

  • Declare Variables:
cpp

int sensorPin1 = A0; int sensorPin2 = A1; int servoPin1 = 9; int servoPin2 = 10;

These variables store the pin numbers for the analog sensors and servo motors.

  • Initialize Variables:
cpp

int sensorValue1 = 0;
int sensorValue2 = 0;
int servoGrad1 = 90;
int servoGrad2 = 90;
int tolerance1 = 40;
int tolerance2 = 30;

These variables store the current sensor readings, servo positions, and tolerance values. servoGrad1 and servoGrad2 represent the angles of the servos, initialized to 90 degrees.

  • Create Servo Objects:
cpp

Servo myservo1;
Servo myservo2;

These objects represent the servo motors.

  • Setup Function:
cpp

void setup()
{
pinMode(sensorPin1, INPUT);
pinMode(sensorPin2, INPUT);
myservo1.attach(servoPin1);
myservo1.write(servoGrad1);
myservo2.attach(servoPin2);
myservo2.write(servoGrad2);
}

Configures the sensor pins as inputs.

Attaches the servo motors to their respective pins.

Initializes the servo positions to 90 degrees.

  • Loop Function:
cpp

void loop()
{
sensorValue1 = analogRead(sensorPin1);
sensorValue2 = analogRead(sensorPin2);
if (sensorValue1 < (512 - tolerance1))
{
if (servoGrad1 < 180) servoGrad1++;
}
if (sensorValue1 > (512 + tolerance1))
{
if (servoGrad1 > 0) servoGrad1--;
} myservo1.write(servoGrad1);
if (sensorValue2 < (512 - tolerance2))
{
if (servoGrad2 < 180) servoGrad2++;
}
if (sensorValue2 > (512 + tolerance2))
{
if (servoGrad2 > 0) servoGrad2--;
}
myservo2.write(servoGrad2);
delay(10); }
  • Reads analog sensor values.
  • Adjusts the servo positions based on the sensor readings and tolerances.
  • Writes the new servo positions.
  • Introduces a delay of 10 milliseconds for stability.

In summary, this code creates a feedback loop that adjusts the positions of two servo motors based on the readings from two analog sensors. The servos will move in response to changes in sensor values, with the specified tolerances to prevent unnecessary movements due to noise in the sensor readings.

I recommend you to replicate my circuit and play with different values so you will know the area of impact, After the simulations are complete we can head over to building the actual circuit.


Step 2: Building the Circuit

Since we already made connections in the prototype making the real connections should not be that hard.

Start by connecting the micro servo to the D9 pin of uno whereas the Gnd and Positive pins are connected to the breadboard power supply rails.

Now connect the LDR to the breadboard and connect one end of the LDR to the power supply and the other end to pin A0 also known as the analog pin of uno.

After this is done connect the power supply USB cable to any power source and connect with uno

If you are exposing the LDR to a light source the servo might move until the motion stops, Now you can place your finger on any LDR now you can see some movements in the servo.

Do that process twice to get two planets moving. If you want more, you can add another breadboard and add more. Add this code in the Arduino Program and test out your project!


*code is attached to assignment because it wouldn't process here*

Step 3: Decoration

This is the decoration I made. Just a quick measurement of the breadboard, paint, and cut outs for the servo motors and the LDR's. Make sure your LDR's aren't blocked by the cardboard so they aren't interfered with and only interact with light.