Submit

18 / 20

Sun-tracking solar panel

Balance two light sensors to aim a servo-mounted panel.

Run this experiment →
ESP32 teaching illustration with module, GPIO headers and lesson components

Why it’s here

Change the sun position and compare sensor difference with panel angle.

How it works

Balance two light sensors to aim a servo-mounted panel. A small difference should not move the servo. The deadband prevents jitter near balance. This guided model targets the original ESP32 and Arduino-ESP32 3.x; radio, acoustics, loads and mechanics are simplified.

Try it

  1. Open this experiment
  2. Change the sun position and compare sensor difference with panel angle.

Connections

  • GPIO 34 / 35 — Left / right LDR dividers · 3V3
  • GPIO 18 — Panel servo

Example sketch

#include <ESP32Servo.h>
Servo arm;
int angle = 90;

void setup() {
  arm.setPeriodHertz(50);
  arm.attach(18, 500, 2400);
}

void loop() {
  int left = analogRead(34), right = analogRead(35);
  if (abs(left - right) > 100) angle = constrain(angle + (right > left ? 1 : -1), 0, 180);
  arm.write(angle);
  delay(30);
}

Check your understanding

Why add a deadband?

Show the answer

A small difference should not move the servo. The deadband prevents jitter near balance.

Sources

Arduino-ESP32 ↗ · GPIO reference ↗

MAKE A THOUGHTFUL CHOICE

Your shortlist, side by side.

Pricing models are indicative. Check each official website for current plans and limits.