We need to drive servos with the GPIO of the primusx board, but we can’t get the pwm outputs to work when using IDE 2.1.0 (win). When we use the following code, the output is stuck high or low, but it is never a PWM signal. It doesn’t matter what output we choose, and we get the same result on both our primusx boards.
#include “PlutoPilot.h”
#include “Peripheral.h”
void plutoInit()
{
}
void onLoopStart()
{
PWM.init(Pin3, 500);
}
void plutoLoop()
{
PWM.write(Pin3, 1000);
}
void onLoopFinish()
{
}
However using IDE 1.0.6-win we can get a PWM output to work on pin2 of the GPIO (on both boards). The code using this older IDE looks like this:
#include “PlutoPilot.h”
#include “Servo.h”
void plutoInit()
{
}
int servoAngle = 1000;
void onPilotStart()
{
}
void plutoPilot()
{
Servo.set(S1, servoAngle);
// toggle pulse width between values 1000 and 2000
if (servoAngle == 1000)
servoAngle = 2000;
else if (servoAngle == 2000)
servoAngle = 1000;
}
void onPilotFinish()
{
}
This code works fine. Any thoughts on what is going on?