This is confusing. Help me understand, You have an LCD display that is not the onion the Huskylens and you want to show the numerical data, as text, on a second display?I would like to send data from the Huskylens (trucking object) and display it on the LCD. The IDE serial monitor shows the correct values (xcenter, ycenter .....) but the LCD shows the value "-1". LCD is I2C, Huskylens UART (RX,TX).
I think my code is correct.
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4);
#include "HUSKYLENS.h"
#include "SoftwareSerial.h"
SoftwareSerial mySerial(10, 11);
HUSKYLENS huskylens;
void setup() {
Serial.begin(115200);
mySerial.begin(9600);
lcd.init(); // inicializace LCD displeje
lcd.backlight(); // zapnutí podsvícení displeje
//huskylens.writeAlgorithm(ALGORITHM_OBJECT_TRACKING);
}
void printResult(HUSKYLENSResult result);
void loop() {
HUSKYLENSResult result = huskylens.read();
int aaa=result.xCenter;
lcd.setCursor(0,2);
lcd.print("stred X: ");
lcd.setCursor(9,2);
lcd.print(aaa);
}
When you say that the proper values appear via the serial monitor, do you mean when you print your variable aaa there, or something else?Thank you for your interest in my problem.
Excerpt from the program code (the entire program code has 450 lines)
I can also send the full code.
C-like:#include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27,20,4); #include "HUSKYLENS.h" #include "SoftwareSerial.h" SoftwareSerial mySerial(10, 11); HUSKYLENS huskylens; void setup() { Serial.begin(115200); mySerial.begin(9600); lcd.init(); // inicializace LCD displeje lcd.backlight(); // zapnutí podsvícení displeje //huskylens.writeAlgorithm(ALGORITHM_OBJECT_TRACKING); } void printResult(HUSKYLENSResult result); void loop() { HUSKYLENSResult result = huskylens.read(); int aaa=result.xCenter; lcd.setCursor(0,2); lcd.print("stred X: "); lcd.setCursor(9,2); lcd.print(aaa); }
Result:else if(result.xCenter>=200)
{
right(); // engine
}
void printResult(HUSKYLENSResult result){
if (result.command == COMMAND_RETURN_BLOCK){
Serial.println(String()+F("Block:xCenter=")+result.xCenter+F(",yCenter=")+result.yCenter+F(",width=")+result.width+F(",height=")+result.height+F(",ID=")+result.ID);
delay(1);
}
else if (result.command == COMMAND_RETURN_ARROW){
Serial.println(String()+F("Arrow:xOrigin=")+result.xOrigin+F(",yOrigin=")+result.yOrigin+F(",xTarget=")+result.xTarget+F(",yTarget=")+result.yTarget+F(",ID=")+result.ID);
delay(1);
}
else{
Serial.println("Object unknown!");
}
delay(2);
}
Print on the LCD display:
HUSKYLENSResult result = huskylens.read();
int aaa=result.xCenter;
//------------------- souradnice objektu -------------------------------------------
lcd.setCursor(0,2);
lcd.print("stred X: ");
lcd.setCursor(9,2);
lcd.print(aaa);
lcd.setCursor(14,2);
lcd.print("Y: ");
lcd.setCursor(17,2);
lcd.print(result.yCenter);
void printResult(HUSKYLENSResult result){
if (result.command == COMMAND_RETURN_BLOCK){
Serial.println(String()+F("Block:xCenter=")+result.xCenter+F(",yCenter=")+result.yCenter+F(",width=")+result.width+F(",height=")+result.height+F(",ID=")+result.ID);
// LCD code here, using result.xCenter
}
else if (result.command == COMMAND_RETURN_ARROW){
Serial.println(String()+F("Arrow:xOrigin=")+result.xOrigin+F(",yOrigin=")+result.yOrigin+F(",xTarget=")+result.xTarget+F(",yTarget=")+result.yTarget+F(",ID=")+result.ID);
}
else{
Serial.println("Object unknown!");
}
}