Skills Dev IV - Akshay Soma

Made by Akshay Soma · UNLISTED (SHOWN IN POOLS)

Create a meaningful experience using a servo

Created: December 4th, 2021

0

Outcome

    • The goal of this project was to use a servo to communicate information in a meaningful way. What I created is a design that moves the servo according to the percentage change in the price of a stock or cryptocurrency. 
    • You will have to use your imagination a little, as I couldn't get my stick notes to stick to the servo. The concept is that at 90-degrees, the change in price is "0%" or the program has only executed for the first time. Each time data is updated, using the particle web console to pass a value to the particle function, the servo will move accordingly.
0
Skills Dev 4 pre capacitor
Akshay - https://youtu.be/RoUx-ygvPU8
0
skills Dev 4 with capacitor
Akshay - https://youtu.be/ZS6pvL-90m4
0
int servoPin = A4;
Servo akshayServo;
int servoPos = 0;
int lastPrice = -1;
int percChange;

void setup() {
    
akshayServo.attach(A4);

Particle.function("servo", servoControl);

Particle.variable("servoPos", &servoPos, INT);
}

void loop() {

}

int servoControl(String command){
  // Convert
   int newPrice = command.toInt();
   // Make sure it is in the right range
   // And set the position

if(lastPrice == -1){
        servoPos = 90;
    }

else{
    
    percChange = (newPrice - lastPrice) / lastPrice;
    
    servoPos = constrain((percChange*10) + 90, 0 , 180);
}
   // Set the servo
   akshayServo.write(servoPos);
   
   lastPrice = newPrice;

   // done
   return 1;
}
Click to Expand
0

Process

My process for this project was a bit frustrating as the servo was being underpowered. After soliciting some advice, I was able to get it to move using the VUSB connection, however no consistently. Often times, the servo needed a small push to actually get moving. Further research led me to understand that a capacitor could be helpful in smoothing the power delivery such that the servo was constantly powered appropriately. As a result, it moved perfectly with each command issued once that capacitor was wired in.

0

Reflection

Reflect on the process of making this project. What did you learn? What would you do differently?

I learned a few things through this project. Namely the importance of consistent power delivery and how a capacitor can help with that. In addition to learning to wire the capacitor in, I learned how to use constraints for function inputs to ensure that you do not pass inexecutable commands. If I were to do one thing differently, it would be to work a little more on the design such that I can exemplify my result more accurately.

x
Share this Project

This project is only listed in this pool. Be considerate and think twice before sharing.


Courses

About

Create a meaningful experience using a servo