Skill Dev IV: Working with Motors

Made by Junke Zhao

Control servo movement with Particle Cloud and create a simple interactive gadget.

Created: December 18th, 2023

0

Product

I have a hanging light on my monitor in my apartment that provides me with good ambient lighting when I'm using my computer monitor, and it also serves as a suitably bright bedtime table lamp before I go to bed. It's remotely controlled by a cylindrical controller that you press down to turn it on and off, and rotate it left or right to adjust its brightness. One problem is that there is only one controller and I use it in two places, in front of my computer and in front of my bed, so I would like to utilize a servo that can be controlled remotely so that I can control the brightness of the lamp without having to travel to another location.

0

Process

As a first step, I used a small servo powered by an Argon microcontroller for circuit connection and code testing.

And next, I connected and fixed the rotary controller of the screen hanging light to the servo to test if the small servo can drive the remote control.

After that, I realized that the smaller servos had less torque to twist the controller, so I replaced the larger servos with external power and rewired the circuit.

0

Outcome

I eventually managed to remotely control the brightness of the lights using the big servos, and I was able to rotate the controller at the right angle to achieve the right brightness by entering commands into the Particle Console. In the next step of my design, I will try to add a motor that I can control to press the controller to turn the lights on and off.

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 );
  Particle.function("servo", servoControl);
  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
0

The effect in the video doesn't look obvious due to the exposure accuracy of the phone recording the video, but it actually does the job well, varying between the darkest and brightest ranges.

x
Share this Project

Courses

48-675 Designing for the Internet of Things

· 11 members

A hands-on introductory course exploring the Internet of Things and connected product experiences.


About

Control servo movement with Particle Cloud and create a simple interactive gadget.