Skills Dev IV - Lulin Shan

Made by Lulin Shan

To create a material interaction using a servo

Created: December 5th, 2021

0

Outcome

In this project, I worked with the servo and created a material interaction to communicate weather conditions.

0

Using a Servo

Following the setup guide on the Lab site, I was able to get my servo moved. I originally had an issue with my servo refusing to move after wiring it per the diagram. After reconnecting the red pin from 3V3 to VUSB, it finally worked.

0
int servoPin = A3;
int servoPosition = 0;

Servo myServo;

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( "servoPosition" , &servoPosition , INT );

}

void loop() {

}

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

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

   // done
   return 1;
}
Click to Expand
0
Using a Servo
Lulin Shan - https://youtu.be/Tp3V3j9OFvs
0

Practice Exercise: Paper Signals

My goal is to have a paper pointer attached to my servo's arm component indicate the weather condition at my friend’s city. My conversations with my friend always start with talking about the weather at each other’s place, so I felt this would be an ambient and meaningful visualization for small talks at the beginning of our communication. I used the Particle Cloud to simulate data coming from an external source and tell the servo to rotate to the desired degrees.

0
int servoPin = A3;
int weatherCondition = 0;

Servo myServo;

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("weather", weatherControl);
   
   // Keep a cloud variable for the current position
   Particle.variable( "weatherCondition" , &weatherCondition , INT );

}

void loop() {

}

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

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

   // done
   return 1;
}
Click to Expand
0
Paper Signals
Lulin Shan - https://youtu.be/cJaUCrQNMdI
0

Reflection

The tutorial was straightforward, and everything worked as required. It is a fun exercise by integrating the circuit with physical materials. I begin to see opportunities for using IoT devices to visualize data in a simple yet informative way. For the final project, we could consider hiding wires in the physical form.  

x