Hi, I have a code for moving a linear actuator in and out that works well in arduino uno but doen’t work in Xiao nRF52840. Can you please tell me what should I do different for it to work?
/* The code will move a linear actuator to position according to a reading from an external pushbutton
Parts required:
- servo motor
- 220 OHM RESISTOR
- Switch (push button)
*/
#include <Servo.h>
Servo myServo;
int const potPin = A0; // analog pin used to connect the pushbutton
int pushVal; // variable to read the value from the analog pin
//int keyVal; // variable to hold the reading from the push button
#define PIN_SERVO (9)
void setup()
{
myServo.attach(PIN_SERVO);
Serial.begin(9600); // open a serial connection to your computer
}
void loop() //go to location according to reading from external potentiometer.
{
pushVal = analogRead(potPin); // read the value of the pushbutton
// print out the value to the Serial Monitor
Serial.print("pushVal: ");
Serial.println(pushVal);
if (pushVal>600){
myServo.writeMicroseconds(1010);
delay(2500);
myServo.writeMicroseconds(1690);
delay(1500);
}
}
I had a similar problem driving a haptic motor with the XIAO nRF52840. It worked on the Arduino, but the XIAO would not run the haptic motor. Not even a little bit. I ended up adding a 2605L haptic driver and it worked great after that. Maybe try something like the Adafruit PCA9685 16-Channel Servo Driver. 16 channels may be a little overdoing it, but it looks fairly small and inexpensive. Or maybe someone makes a single channel. Good luck.
Hi, I’m using an Actuonics linear motor (P8) and it comes with its own driver (Ext-R). Can’t it work in this constellation with Xiao? Maybe I need to change something in the code or use a library other than Servo.h?
Hi there,
According to there web site the (R) variant is Arduino compatible. So it should work,
Be sure the voltage settings, Xiao is a 3.3v device. FYI
HTH
GL PJ
R Series
All of our R-series units use the same 3-wire configuration as rotary RC servos and
are plug and play compatible with most RC receivers. These units can also be
operated via Arduino using the Arduino servo library.
The "R" series are only available as a 6V unit.
I connect 12V externally to the driver so that’s not the problem. I also though it should work, but it doesn’t… Again, in Arduino uno it works well weather I connect it to its 5 ot 3.3V.