Go Down

Topic: Servos in a class - weird behaviour (Read 56 times) previous topic - next topic

jgporteous

Hey everyone,

I've been playing with servos and wanted a separate class with the instances of the servos.

This stumped me for a while, but I've figured out what works and what doesn't and wanted some expert advice on why....


I've uploaded as simple project to https://github.com/JGPorteous/ServoTest

When passing the pin of the servo via the constructor of my custom class, the servo acts like a 3-year old having a tantrum.

If I instantiate an instance of the class, then call a function to attach the servo, it works.

I've had a look at the servo class' code, and feeling stumped.

I have a wild theory it might be related to the memory management of object in the atmel chips, but that might be as irrational as the tantrum mentioned above.

Any ideas?

J

jremington

Misbehaving servos usually result from an inadequate power supply. You need an independent power supply capable of providing 1 ampere per servo. Connect the Arduino and servo power supply grounds together.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy