Arduino (C) code to trigger "learning" button

userHead etothex23 2020-06-28 22:35:10 8661 Views5 Replies
Hello,
I need to be able to trigger the learning button with code. How is this done? Are you going to update the library or can you point me to figuring out how to trigger the learning button?
2022-05-25 15:16:22

Hi, is there a way to solve etothex23 issue today ?

Thank you

userHeadPic johncena
2020-10-29 15:34:53 Hello,
I need to be able to trigger the learning button with code. How is this done? Are you going to update the library or can you point me to figuring out how to trigger the learning button?
You should be able to trigger a learn action by issuing a COMMAND_REQUEST_LEARN (0x36) command with the huskylens.writeLearn() call in Arduino. See Protocol.

See this arduino example:
Code: Select all
#include "HUSKYLENS.h"

HUSKYLENS huskylens;

void setup() 
{
    Serial.begin(115200);
    pinMode(A0,INPUT_PULLUP);
    Wire.begin();
    while (!huskylens.begin(Wire))
    {
        Serial.println(F("Begin failed!"));
        delay(100);
    }
}

void loop() 
{
  if(digitalRead(A0) == 0)
  {
     while (!huskylens.writeLearn(1))  // bool writeLearn(int ID)
    {
      Serial.println(F("learn object ID1 failed!")); 
      delay(100);
    }
    Serial.println(F("learn object ID1 success")); 
  }
}
Each time you'll ground the A0 pin in this example, the Huskylens will learn a new image for ID1. You can adapt the code to learn multiple classes (by using more pins for example). At the end, save the model to SD card to keep it for example. userHeadPic adumont