Salut,
je suis nouveau dans le monde arduino. J'aimerais savoir si c'est possible d'afficher deux caractère different(nombre et symbol) sur une meme ligne et colonne sans que le nombre disparaisse. En bas voila mon code.
Merciiiiii d'avance
#include <LiquidCrystal.h>
#include <stdio.h>// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int val = 0;
double volts= 100.0233;
char *lab[2] = {"U= ", "T= "};
char *Einheit[2] = {“V”, “C”};void setup() {
// turn the LCD on (HIGH is the voltage level)
digitalWrite(37, HIGH);
// set the RW Pin to Write Mode by setting the digital pin to LOW
digitalWrite(36, LOW);// opens serial port, sets data rate to 9600 bps
Serial.begin(9600);
// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);}
void loop()
{ //read from A8
val=analogRead(A8);volts=(val/1024.0)*50000.0;
lcd_print_string(volts, lab[0], Einheit[0], 3, 3, 0, 3);
// wait for a half second
delay(500);
}
// *P_str = val; ===> P_Str = &val;
void lcd_print_string(double value, char label, char unit, unsigned int dec_number, unsigned int dec_places, unsigned int row, unsigned int column)
{
char Out_str_ent[16];
char Out_str[16];
char Out_str_dec[16]; // partie décimaleunsigned int width = dec_number + dec_places+1; // the minimum width is equal to decimal numbers, decimal point and decimal values(digits)
unsigned int real_length_dec_num = strlen(Out_str_ent); //real length of the decimal number ==> target_length_dec_num = dec_number
unsigned int total_length = strlen(Out_str_ent+strlen(Out_str_ent)-dec_number)+strlen(Out_str_dec+1)+strlen(label)+strlen(unit)+1; //total length of the printing value on the LCD incl. label and unitdtostrf(floor(value), dec_number, 0, Out_str_ent); // decimal numbers
dtostrf(value-floor(value), 0, dec_places, Out_str_dec); // decimal places// clears the LCD screen and positions the cursor in the upper-left corner
lcd.clear();
// set the cursor position:
lcd.setCursor(column, row);if (total_length <= 16){
lcd.print(label);
lcd.print(Out_str_ent+strlen(Out_str_ent)-dec_number);
lcd.print(Out_str_dec+1);
lcd.print(" ");
lcd.print(unit);
lcd.setCursor(0,1);
lcd.print(real_length_dec_num);if (real_length_dec_num > dec_number){
lcd.setCursor(column, row);
lcd.print(label);
lcd.print(Out_str_ent+strlen(Out_str_ent)-dec_number);
lcd.print(Out_str_dec+1);
lcd.print(" ");
lcd.print(unit);
lcd.setCursor(strlen(label)+column,0);
//lcd.cursor();
lcd.write(94); /(Ici j’aimerairais afficher le sysmbol Ascii sur la meme ligne et colonne que mon nombre decimal sans que cela ne disparaisse/}
}
}