Week 10: Output Devices

Group Assignment

Click to access the group assignment

My Board

I used my custom ESP32-C3 board from Week 8.

Final Assembly

Wiring

This project uses three output devices. Here's how each is connected:

LED Wiring

Buzzer Wiring

Servo Wiring

Even though the SG90 servo is meant for 5V, it worked for light testing at 3.3V.

Shared Ground

All components share the same ground with the microcontroller to ensure proper signal reference.

Wiring Diagram

Wiring diagram

Finished Setup In Real Life

Hero shot

Programming Process

Arduino IDE code

Source Code


#include <ESP32Servo.h>

#define SERVO_PIN   6  // GPIO 6
#define LED_PIN     2  // GPIO 2
#define BUZZER_PIN  9  // GPIO 9

Servo myServo;

void setup() {
  Serial.begin(115200);
  Serial.println("Starting...");

  pinMode(LED_PIN, OUTPUT);
  pinMode(BUZZER_PIN, OUTPUT);

  myServo.setPeriodHertz(50);
  myServo.attach(SERVO_PIN, 500, 2400);
  myServo.write(0);
  delay(1000);
}

void loop() {
  digitalWrite(LED_PIN, HIGH);
  delay(300);
  digitalWrite(LED_PIN, LOW);
  delay(300);

  digitalWrite(BUZZER_PIN, HIGH);
  delay(100);
  digitalWrite(BUZZER_PIN, LOW);
  delay(400);

  for (int angle = 0; angle <= 180; angle += 30) {
    myServo.write(angle);
    delay(300);
  }

  for (int angle = 180; angle >= 0; angle -= 30) {
    myServo.write(angle);
    delay(300);
  }
}
  

Problems & Solutions

Video of the Working Setup

What I Learned

Hero Shot

Hero shot