Skip to content

Output devices

The objectives of this week are to learn how to interact with an LCD display to send and show data in individual assignments and to assess the power consumption of OLEDs in group projects.

This week I will focus this week on output devices, something lke speakers, video systems, servo motors, and displays.

Group Assignment

In the group assignment, we attempted to measure the power consumption of an OLED display using four power meters.

Individual Assignment

Servo motors are precision-engineered devices designed to deliver accurate control over position, speed, and acceleration. They utilize advanced feedback systems, which set them apart from other motor types like stepper and DC motors. Unlike these alternatives, servo motors excel in complex motion tasks, thanks to their dynamic feedback loops that ensure high accurac

For my individual asingment I used a stepper motor So i used this code to connect it I connected it to the 10th port

this is some code chat gpt generated with this prompt - generate an example code for a servo on a seedstudio XIAO ESP-32_C2

#include <ESP32Servo.h>

Servo myservo;

int servoPin = 10;  // D10 = GPIO10 on XIAO ESP32-C3
int pos = 0;

void setup() {
  // Allocate timers (required for ESP32)
  ESP32PWM::allocateTimer(0);
  ESP32PWM::allocateTimer(1);
  ESP32PWM::allocateTimer(2);
  ESP32PWM::allocateTimer(3);

  myservo.setPeriodHertz(50);              // standard servo frequency
  myservo.attach(servoPin, 1000, 2000);   // attach to GPIO10
}

void loop() {
  // Sweep from 0 to 180
  for (pos = 0; pos <= 180; pos++) {
    myservo.write(pos);
    delay(5);
  }

  // Sweep back from 180 to 0
  for (pos = 180; pos >= 0; pos--) {
    myservo.write(pos);
    delay(15);
  }
}

This program controls a servo motor and makes it sweep back and forth continuously.

So the servo starts at 0 degrees, and in the main loop it just keeps going step by step up to 180. Each little move has this 15 millisecond pause, I think thats what makes it look smooth instead of jerky.

Connected it to the ESP_32 and it runs perfectly connected it to the ports alt text Connected the brown to the groud the red to the 5v and the input to the D10 alt text