Grace Skills Dev IV

Made by Grace Zhu

Get oriented with output and feedback by working with an actuator.

Created: November 20th, 2024

0

Intention

For this project I explored how to use servo to build a paper desktop item. I decided to build a human figure and have their mouth to be the moving part.

0

Process

I first practiced using the servo motor and then created a graphic that will work with the rotating motion. Later I adjusted the speed with ChatGPT's help.

0

Outcome

I successfully made the mouth piece to move as I input a degree (15 - 0). The motor rotates and creates the movement effect.

0

Reflection

It was a little hard to imagine how the parts will move sometimes. I found it helpful to test with the moving part first before assembling everything.

0
int servoPin = A5;
int servoPosition = 0;
Servo servo;

void setup()
{
  Serial.begin( 9600 );
  Particle.function( "pos", setPosition );
  servo.attach( servoPin );
}

void loop()
{
  delay(100);
}

int setPosition(String command) {
    Serial.println("setSpeed: " + command);

    int value = command.toInt();
    if (value < 0) return -1;
    if (value > 180) return -1;

    int targetPosition = constrain(value, 0, 180);

    // Gradually move to the new position
    while (servoPosition != targetPosition) {
        if (servoPosition < targetPosition) {
            servoPosition++; // Increment position
        } else if (servoPosition > targetPosition) {
            servoPosition--; // Decrement position
        }

        servo.write(servoPosition); // Update servo position
        delay(20); // Adjust delay to control speed (lower = faster, higher = slower)
    }

    return 1;
}
Click to Expand
0
Motor Project
Grace Z - https://youtu.be/6FUyLd94R1E
x
Share this Project


About

Get oriented with output and feedback by working with an actuator.