Skills Dev IV - Lulin Shan
Made by Lulin Shan
Made by Lulin Shan
To create a material interaction using a servo
Created: December 5th, 2021
In this project, I worked with the servo and created a material interaction to communicate weather conditions.
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
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.
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
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.