This runs fine for servo1 (servo2 commented out).
It runs fine for servo2 (servo1 commented out).
However if I instantiate both server1 and servo2, server1 does nothing and server2 judders and moves eratically.
If I add the 'print(this.pin);' to the 'p' function:
It runs fine for servo1 (servo2 commented out) I get C5 echoed to the console (this is correct).
It runs fine for servo2 (servo1 commented out) I get C6 echoed to the console (this is correct).
However if I instantiate both server1 and servo2, server1 does nothing and server2 judders and moves eratically I get C6 echoed to the console (I would expect C6 and C5 in roughly equal amounts).
My conclusion is that I am instantiating two objects but the 'p' method is piching the values from the last one instantiated.
I am also working on stepper motors and radio recivers and would like to define objects to encapsulate their behaviour as well.
Could you please help me understand what is going on and how to fix this. Eventually I would like to operate several servos this way.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi
I am attempting to create an Object that encapsulates a servo motor and I seen to have come unstuck!
The following the significant part of my code for the Servo object:
Note ref:
is where I picked up the pattern for setting up 'p' and the setInterval function.
Hope I got the formatting right this time !-)
This runs fine for servo1 (servo2 commented out).
It runs fine for servo2 (servo1 commented out).
However if I instantiate both server1 and servo2, server1 does nothing and server2 judders and moves eratically.
If I add the 'print(this.pin);' to the 'p' function:
It runs fine for servo1 (servo2 commented out) I get C5 echoed to the console (this is correct).
It runs fine for servo2 (servo1 commented out) I get C6 echoed to the console (this is correct).
However if I instantiate both server1 and servo2, server1 does nothing and server2 judders and moves eratically I get C6 echoed to the console (I would expect C6 and C5 in roughly equal amounts).
My conclusion is that I am instantiating two objects but the 'p' method is piching the values from the last one instantiated.
I am also working on stepper motors and radio recivers and would like to define objects to encapsulate their behaviour as well.
Could you please help me understand what is going on and how to fix this. Eventually I would like to operate several servos this way.
Thanks
Stuart