Skills Dev IV: Working with Outputs - Motors and Movement

Made by Yanling Zhang

Created: December 4th, 2021

0

I use the character Boji from "Ranking of Kings" to make this small installation. When the user types a different number such as "5" or " 175", the Boji's look will change.

0
int servoPin = A3;
Servo myServo;
int servoPos = 0;

void setup() {

  // attaches the servo on the A3 pin to the servo object
  myServo.attach( A3 );

   //Register our Particle to control the servo
   Particle.function("servo", servoControl);

  // Keep a cloud variable for the current position
  Particle.variable(  "servoPos" , &servoPos , INT );


}


void loop() {

}


int servoControl(String command)
{
    // Convert
   int newPos = command.toInt();
   // Make sure it is in the right range
   // And set the position
   servoPos = constrain( newPos, 0 , 180);

   // Set the servo
   myServo.write( servoPos );

   // done
   return 1;
}
Click to Expand
0
skill dev 4
zhang yanling - https://youtu.be/a9MLUak305k
0

Reflection

It is challenging to combine two mouths into one circle. I have experimented several times to match the eyes with two mouths. 

It is important to match the gesture and motor movement types to make the installation vivid.

x