huskylens can`t work

userHead Jung.Kiyoung 2023-10-04 16:55:44 803 Views7 Replies

Hello
I'm studying Husky Lens
After a certain period of time
Husky lens doesn't seem to be able to call data values
So the digital Write output doesn't change
How do I solve this?
 

 

Here's the source code here

 


#include "HUSKYLENS.h"


HUSKYLENS huskylens;

//HUSKYLENS green line >> Pin 10; blue line >> Pin
void printResult(HUSKYLENSResult result);
int out = 9;
bool flag_led = 0;
int led_cnt = 0;

void setup() {
 Serial.begin(9600);
 pinMode(out, OUTPUT);
 pinMode(13, OUTPUT);
 Wire.begin();

 Serial.println("system start");
  while (!huskylens.begin(Wire))
   {
       Serial.println(F("Begin failed!"));
       Serial.println(F("1.Please recheck the \"Protocol Type\" in HUSKYLENS (General Settings>>Protocol Type>>I2C)"));
       Serial.println(F("2.Please recheck the connection."));
       delay(100);
   }

}

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 = huskylens.read();
           printResult(result);
       }    

   led_cnt++;
   if(led_cnt >= 50)
   {
     led_cnt = 0;
     flag_led ^= 0x01;

     digitalWrite(13, flag_led);
   }
   Serial.print(led_cnt);
   Serial.print("  ");

  delay(100);
  printResult(result);
 }

void printResult(HUSKYLENSResult result) {

 if (result.command == COMMAND_RETURN_BLOCK) {
   if(result.ID == 1) {
     digitalWrite(out, HIGH);
     Serial.println("on");
   }
   if (result.ID == 2){
     digitalWrite(out, LOW); 
     Serial.println("off");
   }
  
 }
}

2024-01-01 21:14:50

Thank you for sharing this information and your experience!

userHeadPic SaraJampen
2023-10-05 01:33:44

Hi, how are you powering up the Huskeylens? 

userHeadPic lia.ifat
Jung.Kiyoung wrote:

Thank you for your answer.

I'm using 5V at Arduino Uno 

Unoboard is powered by a 5V USB adapter

 

2023-10-05 08:47:00
lia.ifat wrote:

I think you must use a separate power supply. Here are some tips about the power supply.

Tips:

You can connect either USB port or 4pin port to power HuskyLens.

Due to the onboard power supply automatic switching circuit, the USB port and the 4pin port can be connected to the power supply at the same time, and the power supply on the USB port is used first.

Please ensure that the supply voltage and rate are sufficient to prevent HuskyLens from working abnormally.

 

Source: https://wiki.dfrobot.com/HUSKYLENS_V1.0_SKU_SEN0305_SEN0336

2023-10-16 02:44:22
Jung.Kiyoung wrote:

Thank you for your answer.Add additional power and reconnect the wiresIt's gotten a lot betterThank you. Have a nice day

2023-10-16 13:17:44
3 Replies