HuskyLens is an easy-to-use AI machine vision sensor. It is equipped with multiple functions, such as face recognition, object tracking, object recognition, line tracking, color recognition, and tag(QR code) recognition.
By baspacc

I'm working on adapting GS-9018 servos to build pan-tilt mechanism for Huskylens. I'm using the basic example (HUSKYLENS_GET_STARED.ino) and added servo support by including Servo library.

The moment I initialize the servos (mysevo.attach), the PWM output starts to quickly rotate the servos in a very "shaky" manner towards one direction. My current code does not do anything with the PWM outputs. I anticipate it's the Huskylens library, since everytime a face is recognized, the servos return to default position. Only the PWM outputs I initialize in the code cause this.

If I upload some basic servo example, evertyhing works fine - the servos follow the instructions and stay still if nothing is being sent. I'm using Arduino Micro, digital PWM outputs, Huskylens in Serial 9600 mode via softserial and an external power supply. FW 4.7 (Stable, with models). What could be the problem? What is the reason the PWM outputs start to control the servos without any instructions in my code?
So far I have managed to identify that it is the request() function that is causing this behavior. If I remove the huskylens.request() call from the code, the odd behavior of servos stops. Of course now the communication with Huskylens does not work anymore.

request function has rather compact body:
return processReturn();

Unfortunately I'm not able to locate protocolWriteRequest() function body, so this is the point I'm stuck at. Any hints appreciated. :)

EDIT: Solved (or rather went around it) by moving to I2C. Still, would love to understand what the problem is. :)
If this is multithreaded, the interrupt signal from the soft serial husky will disturb the PWM signal of the rudder, making the rudder not function properly, if this problem does not occur within a thread.
Could you please share your code?

It's basically the example code delivered with the library. The only thing I added is Servo library declaration and servo initialization. No servo movement commands yet. That's enought for the problem to appear. Marked changes to the example with "//<---".
Code: Select all
#include "HUSKYLENS.h"
#include "SoftwareSerial.h"
#include <Servo.h>                    //<---

Servo myServo1;                       //<---

HUSKYLENS huskylens;
SoftwareSerial mySerial(10, 11); // RX, TX
void printResult(HUSKYLENSResult result);

void setup() {
    myServo1.attach(5);              //<---
    while (!huskylens.begin(mySerial))
        Serial.println(F("Begin failed!"));
        Serial.println(F("1.Please recheck the \"Protocol Type\" in HUSKYLENS (General Settings>>Protocol Type>>Serial 9600)"));
        Serial.println(F("2.Please recheck the connection."));

void loop() {
    if (!huskylens.request()) Serial.println(F("Fail to request data from HUSKYLENS, recheck the connection!"));
    else if(!huskylens.isLearned()) Serial.println(F("Nothing learned, press learn button on HUSKYLENS to learn one!"));
    else if(!huskylens.available()) Serial.println(F("No block or arrow appears on the screen!"));
        while (huskylens.available())
            HUSKYLENSResult result =;

void printResult(HUSKYLENSResult result){
    if (result.command == COMMAND_RETURN_BLOCK){
    else if (result.command == COMMAND_RETURN_ARROW){
        Serial.println("Object unknown!");
I didn't have these servo issues and to be honest I don't know much about coding so I could definitely be way off here but last night when I tried to serial monitor the (HUSKYLENS_GET_STARED.ino) The serial monitor only showed basically backwards question marks and other non-identifiable characters. Even after I verified I was on 9600 protocol about 5 times. Finally in the program I changed the "Serial.begin(115200)" to "Serial.begin(9600)" and it worked perfectly fine. I started getting the correct feedback on the serial monitor. Not sure if this is somehow related to the servo but yeah.