4duino with Arduino IDE

Hello everybody :slight_smile:

I have this Arduino : 4duino - https://store.arduino.cc/4duino-24-lcd

I have a problem with my program, I plugged into my arduino a laser distance detector (Lidar 3). Remote reading works completely but the measurements are displayed in the serial monitor. I would like the distance measurements to be displayed on the screen even if it is in the middle I will adapt the code after but I can not display anything on the screen.
Could someone help me please?
Advanced thanks for your help :slight_smile:

This is my code for the moment :

#include <Wire.h>
#include <LIDARLite.h>
#include "Picaso_Serial_4DLib.h"
#include "Picaso_Const4D.h"

// Globals
LIDARLite lidarLite;
int cal_cnt = 0;
int Laser = 10;
void setup()
{
Serial.begin(9600); // Initialiser la connexion série pour afficher les lectures de distance

lidarLite.begin(0, true); // Définir la configuration par défaut et I2C sur 400 kHz
lidarLite.configure(0); // Changer ce nombre pour essayer d'autres configurations
pinMode(Laser, OUTPUT);
}

void loop()
{
int dist;

// Au début de chaque centaines de lectures,
// prendre une mesure avec correction de polarisation du récepteur
if ( cal_cnt == 0 ) {
dist = lidarLite.distance(); // Avec correction bias
} else {
dist = lidarLite.distance(false); // Sans correction bias
}

// Incrémenter le compteur de lecture
cal_cnt++;
cal_cnt = cal_cnt % 100;

// afficher la distance
Serial.print(dist);
Serial.println(" cm");

//Allumer le Laser losqu'un obstacle franchit la distance choisie
if (dist < 50){
digitalWrite(Laser,HIGH);}

else {
digitalWrite(Laser,LOW);}
}

You forgot the code tags!

I cannot find any statement in that code that would access the Picaso display. Have you had a look at the Display_print example that comes with the library you included in above sketch?

I don't understand anything on Arduino command from the display exemple program.

I've join the program.

Can you explain to me what is string char and float ?

I would like just display something at the middle of my screen i will adapt the code for my project after

could you help me please?

This is the program:

//Simple Demo that demonstrates 'print' and 'println' new functionality.

#define DisplaySerial Serial

//-------Picaso DISPLAYS-------

#include <Picaso_Const4D.h>
#include <Picaso_Serial_4DLib.h>

//use Serial0 to communicate with the display.
Picaso_Serial_4DLib Display(&DisplaySerial);

//---------END-----------------

void setup() {
//For handling errors
Display.Callback4D = mycallback ;

//5 second timeout on all commands
Display.TimeLimit4D = 5000 ;

DisplaySerial.begin(9600) ;

//--------------------------------Optional reset routine-----------------------------------
//Reset the Display using D4 of the Arduino (if using the new 4D Arduino Adaptor - Rev 2)
//If using the old 4D Arduino Adaptor (Rev 1), change D4 to D2 below.
//If using jumper wires, reverse the logic states below.
//Refer to the accompanying application note for important information.
pinMode(4, OUTPUT); // Set D4 on Arduino to Output (4D Arduino Adaptor V2 - Display Reset)
digitalWrite(4, 1); // Reset the Display via D4
delay(100);
digitalWrite(4, 0); // unReset the Display via D4
//-----------------------------------------END---------------------------------------------

delay (5000); //let the display start up

Display.gfx_ScreenMode(PORTRAIT);
//Display.gfx_BGcolour(WHITE) ; //change background color to white
Display.gfx_Cls(); //clear the screen

char a = 'A';
char a2 = 'B';
int b = 1234;
int b2 = -1234;
long c = 123456;
long c2 = -123456;
String string = "This is string class";
char charr[30] = "This is const char array";
float d = 123.456789;
float d2 = -123.456789;
float nan = NAN;
float inf = INFINITY;
float ovf1 = 5294967040.0;
float ovf2 = -5294967040.0;

Display.print(a); Display.print(' ');
Display.println(a2);
Display.print(b); Display.print(' ');
Display.println(b2);
Display.print(c); Display.print(' ');
Display.println(c2);
Display.println("This is String");
Display.println(F("This is Flashstring")); // COMMENT OUT FOR ARDUINO DUE, NOT SUPPORTED
Display.println(string);
Display.println(charr);
Display.println(d,6);
Display.println(d2, 3);
Display.println(nan);
Display.println(inf);
Display.println(ovf1);
Display.println(ovf2);

}

void loop()
{

}

void mycallback(int ErrCode, unsigned char Errorbyte)
{
// Pin 13 has an LED connected on most Arduino boards. Just give it a name
int led = 13;
pinMode(led, OUTPUT);
while(1)
{
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200); // wait for 200 ms
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(200); // wait for 200 ms
}
}

Picaso-Serial-Arduino-Library-master.zip (34 KB)

Go and edit your post to have code tags around the code!

That code is simply the example code.

Can you explain to me what is string char and float ?

A String is a class of the Arduino environment that you shouldn't use because of it's memory wasting. Char is the type for a single character (or byte). Float is a type for a floating point number (single precision, but the Arduino AVR platform doesn't support double precision floating point numbers).
As you have to ask that, it seems you should start with easier projects than integrating a LIDAR with a graphical display.

I would like just display something at the middle of my screen i will adapt the code for my project after

This is not a free programming service. We won't do your task and write that program. Start learning how the Arduino platform works with simple examples that you extend to learn how things are built. Once you get some knowledge about the language and the specific Arduino environment you can try to combine the two sketches you have to achieve your goal above. If that sketch doesn't work as expected, post it's source code here and we will try to help you. But we'll be giving you hints and not write it ourselves.

Hello,

So i've started coding

This is my code but nothing is display on the screen...

#define DisplaySerial Serial
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#include <Wire.h>
#include <LIDARLite.h>
#include "Picaso_Serial_4DLib.h"
#include "Picaso_Const4D.h"
//use Serial0 to communicate with the display.
Picaso_Serial_4DLib Display(&DisplaySerial);
// Globals
LIDARLite lidarLite;
int cal_cnt = 0;
int Laser = 10;
void setup()
{
{
//5 second timeout on all commands
Display.TimeLimit4D = 5000 ;
DisplaySerial.begin(9600) ;
delay (5000); //let the display start up
Display.gfx_ScreenMode(PORTRAIT);
Display.gfx_BGcolour(BLUE) ; //change background color to white
}
{
Serial.begin(9600); // Initialiser la connexion série pour afficher les lectures de distance
lidarLite.begin(0, true); // Définir la configuration par défaut et I2C sur 400 kHz
lidarLite.configure(0); // Changer ce nombre pour essayer d'autres configurations
pinMode(Laser, OUTPUT);
}
}

void loop()
{
int dist;

// Au début de chaque centaines de lectures,
// prendre une mesure avec correction de polarisation du récepteur
if ( cal_cnt == 0 ) {
dist = lidarLite.distance(); // Avec correction bias
} else {
dist = lidarLite.distance(false); // Sans correction bias
}

// Incrémenter le compteur de lecture
cal_cnt++;
cal_cnt = cal_cnt % 100;

// afficher la distance
Serial.print(dist);
Serial.println(" cm");

//Allumer le Laser losqu'un obstacle franchit la distance choisie
if (dist < 50){
digitalWrite(Laser,HIGH);}

else {
digitalWrite(Laser,LOW);}
Display.gfx_println(dist);
}

I've join the picture who show what the screen displaying.

Still no code tags, I won't look at the code if you don't edit your posts and insert code tags!