GLCD sensding pot value to display

hi. im trying to use glcd instead of standard lcd and for tutorial im using pot on A7(0-1024).

when i do:

void loop()                     
{
  int sensorValue = analogRead(pot);
Serial.println(sensorValue);

glcd.drawstring(50, 0, sensorValue);
glcd.display();


}

i get

st7565lcd.pde: In function 'void loop()':
st7565lcd:57: error: invalid conversion from 'int' to 'char*'
st7565lcd:57: error: initializing argument 3 of 'void ST7565::drawstring(uint8_t, uint8_t, char*)'
thanks for any answer

Its looking for a null terminated string, so you could use this.

char Val[5]; // make globally

sprintf(Val, "%d", sensorValue);
glcd.drawstring(50, 0, sensorValue);

Or you can do it simply as: (not tested)

for(int i = 0; i < 4; i++)
{
  Val[i] = sensorValue / pow(10, 3-i));
}
Val[4] = '\0';

can you please explain what are they related to

char Val[5]; // make globally

sprintf(Val, "%d", sensorValue);

its something new to me.

Thanks

Same error with yous suggestion.

:cold_sweat: Oh, I didn't fix it, change
glcd.drawstring(50, 0, sensorValue); to glcd.drawstring(50, 0, Val);

can you please explain what are they related to
char Val[5]; // make globally

sprintf(Val, "%d", sensorValue);

Certainly.

char Val[5] is a char array of 5 elements. (need enough room to hold 1023 + Null terminator)

sprintf(Val, "%d", sensorValue); This will take your numerical value from the Pot and convert it to single chars and store them in the Val array.

i have to ask you for something else also.
within my old lcd i used
if (pressure<-10)

 {
    lcd.setCursor(3,0);
    lcd.print(pressure,0);
  }          
    if (pressure>-10)
  {
    lcd.setCursor(4,0);
    lcd.write(254);
    lcd.setCursor(3,0);
    lcd.print(pressure,0);
  }
    if (pressure>-100)
  {
    lcd.setCursor(5,0);
    lcd.write(254);
    lcd.setCursor(3,0);
    lcd.print(pressure,0);
  }
   if (pressure<0)
  {
    lcd.setCursor(5,0);
    lcd.write(254);
    lcd.setCursor(3,0);
    lcd.print(pressure,0);
  }

to shift cursor to properly display value

with this glcd (st7656) i cannot find a how to guide.
do you have any suggestions??
Thanks

Post your full sketch and a link to your library.

It`s messy

#include "ST7565.h"

int redPin = 12;
int greenPin = 11;
int bluePin = 10;
int pot = A7;
char Val[5]; 


// pin 9 - Serial data out (SID)
// pin 8 - Serial clock out (SCLK)
// pin 7 - Data/Command select (RS or A0)
// pin 6 - LCD reset (RST)
// pin 5 - LCD chip select (CS)
ST7565 glcd(9, 8, 7, 6, 5);

#define LOGO16_GLCD_HEIGHT 16 
#define LOGO16_GLCD_WIDTH  16 

// a bitmap of a 16x16 fruit icon
static unsigned char __attribute__ ((progmem)) logo16_glcd_bmp[]={
0x30, 0xf0, 0xf0, 0xf0, 0xf0, 0x30, 0xf8, 0xbe, 0x9f, 0xff, 0xf8, 0xc0, 0xc0, 0xc0, 0x80, 0x00, 
0x20, 0x3c, 0x3f, 0x3f, 0x1f, 0x19, 0x1f, 0x7b, 0xfb, 0xfe, 0xfe, 0x07, 0x07, 0x07, 0x03, 0x00, };

// The setup() method runs once, when the sketch starts
void setup()   {                
  Serial.begin(9600);

  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT); 
  pinMode(pot, INPUT);
  

  // initialize and set the contrast to 0x18
  glcd.begin(0x18);

  glcd.display(); // show splashscreen
  delay(2000);
  glcd.clear();
  glcd.drawstring(5, 0, "test ");
  glcd.drawstring(50, 2, "test ");
  glcd.drawstring(100, 4, "test ");
  glcd.drawstring(40, 6, "test ");
  glcd.display(); //exec command above otherwise nothing will be visible.
  
  

  
}


void loop()                     
{
  int sensorValue = analogRead(pot);
Serial.println(sensorValue);
int raw;
  float voltage;
  float pressure;       //pressure in psi
  
  // Calculate the input voltage
 // Using the full input range of 5V.
 // The pressure is with a linear scale.
 // 0.5 V = 0 psi
 // 4.5 V = 150 psi
 // That is 37.5 psi per voltage.
 // At 0.5V the pressure is 0 psi
 
 
 //Sensor #1
 raw = analogRead(A7);
 voltage = (float) raw / 1023.0 * 5.0;
 pressure = (((float)analogRead(pot) / 1023.0 * 5.0) - 0.5) * 37.5; 

sprintf(Val, "%d", sensorValue);
glcd.drawstring(50, 0, Val);
glcd.display();


}

and this is my original working code for 16x2 standard lcd

/*
 5 ANALOG PRESSURE SENSORS

 */

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int analogPin = 0;
int sensorValue = 1;
int sensorValue2 = 2;
int sensorValue3 = 3;
int sensorValue4 = 4;
int sensorValue5 = 5;
int val = 0;

void setup() {
  
  Serial.begin(9600);

  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.setCursor(5, 0);
  lcd.print("test");
  lcd.setCursor(3, 1);
  lcd.print("test");
  delay(5000);
  lcd.clear();
  lcd.print("FL      FR      ");
  lcd.setCursor(0, 1);
  lcd.print("RL      RR      ");
  

}
void loop() {
  int raw;
  float voltage;
  float pressure;       //pressure in psi
  
  
  // read the input pin
  
  
  
  // Calculate the input voltage
 // Using the full input range of 5V.
 // The pressure is with a linear scale.
 // 0.5 V = 0 psi
 // 4.5 V = 150 psi
 // That is 37.5 psi per voltage.
 // At 0.5V the pressure is 0 psi
 
 
 //Sensor #1
 raw = analogRead(A1);
 voltage = (float) raw / 1023.0 * 5.0;
 pressure = (((float)analogRead(A1) / 1023.0 * 5.0) - 0.5) * 37.5; 
   
    if (pressure<-10)
  {
    lcd.setCursor(3,0);
    lcd.print(pressure,0);
  }          
    if (pressure>-10)
  {
    lcd.setCursor(4,0);
    lcd.write(254);
    lcd.setCursor(3,0);
    lcd.print(pressure,0);
  }
    if (pressure>-100)
  {
    lcd.setCursor(5,0);
    lcd.write(254);
    lcd.setCursor(3,0);
    lcd.print(pressure,0);
  }
   if (pressure<0)
  {
    lcd.setCursor(5,0);
    lcd.write(254);
    lcd.setCursor(3,0);
    lcd.print(pressure,0);
  }   

  
    

 //Sensor #2
 raw = analogRead(A2);
 voltage = (float) raw / 1023* 5.0;
 pressure = (((float)analogRead(A2) / 1023.0 * 5.0) - 0.5) * 37.5;
 
 if (pressure<-10)
  {
    lcd.setCursor(11,0);
    lcd.print(pressure,0);
  }          
    if (pressure>-10)
  {
    lcd.setCursor(12,0);
    lcd.write(254);
    lcd.setCursor(11,0);
    lcd.print(pressure,0);
  }
    if (pressure>-100)
  {
    lcd.setCursor(13,0);
    lcd.write(254);
    lcd.setCursor(11,0);
    lcd.print(pressure,0);
  }
   if (pressure<0)
  {
    lcd.setCursor(13,0);
    lcd.write(254);
    lcd.setCursor(11,0);
    lcd.print(pressure,0);
  }
 
 
 
        
 //Sensor #3
 raw = analogRead(A3);
 voltage = (float) raw / 1023* 5.0;
 pressure = (((float)analogRead(A3) / 1023.0 * 5.0) - 0.5) * 37.5;
      
    
  if (pressure<-10)
  {
    lcd.setCursor(3,1);
    lcd.print(pressure,0);
  }          
    if (pressure>-10)
  {
    lcd.setCursor(4,1);
    lcd.write(254);
    lcd.setCursor(3,1);
    lcd.print(pressure,0);
  }
    if (pressure>-100)
  {
    lcd.setCursor(5,1);
    lcd.write(254);
    lcd.setCursor(3,1);
    lcd.print(pressure,0);
  }
   if (pressure<0)
  {
    lcd.setCursor(5,1);
    lcd.write(254);
    lcd.setCursor(3,1);
    lcd.print(pressure,0);
  }   
 
 //Sensor #4
 raw = analogRead(A4);
 voltage = (float) raw / 1023* 5.0;
 pressure = (((float)analogRead(A4) / 1023.0 * 5.0) - 0.5) * 37.5;
      
 
  if (pressure<-10)
  {
    lcd.setCursor(11,1);
    lcd.print(pressure,0);
  }          
    if (pressure>-10)
  {
    lcd.setCursor(12,1);
    lcd.write(254);
    lcd.setCursor(11,1);
    lcd.print(pressure,0);
  }
    if (pressure>-100)
  {
    lcd.setCursor(13,1);
    lcd.write(254);
    lcd.setCursor(11,1);
    lcd.print(pressure,0);
  }
   if (pressure<0)
  {
    lcd.setCursor(13,1);
    lcd.write(254);
    lcd.setCursor(11,1);
    lcd.print(pressure,0);
  }
 
                 
        
 //Sensor #5
 raw = analogRead(A5);
 voltage = (float) raw / 1023* 5.0;
 pressure = (((float)analogRead(A5) / 1023.0 * 5.0) - 0.5) * 37.5;


val = analogRead(analogPin);
  Serial.println(val);
  
}

You would need to adjust these to move your text around.

glcd.drawstring(50, 0, Val);
50 = 50 pixels right on the X axis
0 = 0 pixels down on the Y axis.

If you want, you can keep the X and Y values the same and just use IF statements to add empty spaces after the number to prevent residual numbers from being on the screen.

The color tags are so annoying.

if(sensorValue < 1000)
{  
glcd.drawstring(50, 0, Val);  
glcd.drawstring(/* play with this value*/, 0, " "); // show empty space
}
else if(sensorValue < 100)
{  
  glcd.drawstring(50, 0, Val);
  glcd.drawstring(/* play with this value*/, 0, "  "); // show 2 empty spaces
}
else if(sensorValue < 10)
{ 
 glcd.drawstring(50, 0, Val);
  glcd.drawstring(/* play with this value*/,0, "   "); // show 3 empty spaces
}

This is getting real advanced for me:)
don`t you know any "idiot" tutorial for those glcd?
i need to setup larger fonts as well sometime and make some kind of a column 4px width and20px tall when sensor reach full pressure.

Thanks for your time

Youtube is bound to have something. The best you can do is look at what functions come with the library and just play with everything. Draw boxes, circles, print text, everything.

this is what i`m trying to do for about 3 days now.

The moving column would be easy since you already have a fillRect() function, so you will need two of them to do what you want.

You can try this function, NOTE: I can not test it on my end, so you will need to tell/show me what it does.

void Bar(int value, int low, int high, int x, int y, int w, int h, int F_color, int B_color)
{
  static int lastV = -1, move = 0;
  int Val = map(value, low, high, h, y);
  
  if (Val != lastV) // prevents it from constantly being redrawn on the screen
  {
    if ( Val > lastV)
    {
      for (move; move < Val; move++)
      {
        glcd.fillRect(x, y, w + 1, (h - 1) - move, F_color);
      }
      lastV = Val;
    }
    else
    {
      for (move; move > (lastV + 1); move--)
      {
        glcd.fillRect(x + w, y + h, w + 1, (h - 1) + move, B_color);
      }
      lastV = Val;
    }
  }
}

value -> is what you will show with the bar
low -> is the lowest the "value" can go
high -> is the highest the "value" can go
*(x/y) & (*w/h) -> where you want it can how tall and wide it will be
F_color -> the color that will indicate the value level
B_color -> background color

im still trying to shift spaces to display all in the right order. and is finnaly worked but now first value gone (0-1023 display space on 1 and 023)

void loop()                     
{
  int sensorValue = analogRead(pot);
Serial.println(sensorValue);


sprintf(Val, "%d", sensorValue);
glcd.drawstring(50, 0, Val);


if(sensorValue < 1000)
{  
glcd.drawstring(50, 0, Val);  
glcd.drawstring(68, 0, " "); // show empty space
}

if(sensorValue < 100)
{  
  glcd.drawstring(50, 0, Val);
  glcd.drawstring(62, 0, "  "); // show 2 empty spaces
}

if(sensorValue < 10)
{ 
 glcd.drawstring(50, 0, Val);
  glcd.drawstring(56,0, "   "); // show 3 empty spaces
}

glcd.display();
}
void loop()
{
  int sensorValue = analogRead(pot);
  Serial.println(sensorValue);

  sprintf(Val, "%d", sensorValue);

  if (sensorValue < 1000)
  {
    glcd.drawstring(50, 0, Val);
    glcd.drawstring(68, 0, " "); // show empty space
  }
  else if (sensorValue < 100)
  {
    glcd.drawstring(50, 0, Val);
    glcd.drawstring(62, 0, "  "); // show 2 empty spaces
  }
  else if (sensorValue < 10)
  {
    glcd.drawstring(50, 0, Val);
    glcd.drawstring(56, 0, "   "); // show 3 empty spaces
  }
  else glcd.drawstring(50, 0, Val);

  glcd.display();
}

Use this one.

You really need to learn the library and just play with it.

im just not making it clear the whole space alocation works great. it just the matther of displaying value 1023... i only have 023. dont know how to make it more clear
serial shows value 1023 display only 023

I dont know what is causing that issue.

ok. so i moved glcd.drawstring() into the loop and at the end i exec glcd.clear()
this is the only way i could get it working with out issue.
tomorrow i`ll try this graph you posted before.

void loop()                     
{
  
  
  
  int sensorValue = analogRead(pot);
Serial.println(sensorValue);
glcd.drawstring(0, 0, "TEST ");
glcd.drawstring(50, 1, "TEST ");
glcd.drawstring(52, 3, "TEST ");
glcd.fillcircle(32, 32, 10, BLACK);
glcd.fillcircle(100, 32, 10, BLACK);

sprintf(Val, "%d", sensorValue);
glcd.drawstring(50, 0, Val);

if(sensorValue < 1000)
{  
glcd.drawstring(50, 0, Val);  
glcd.drawstring(68, 0, " "); // show empty space

}

else if(sensorValue < 100)
{  
  glcd.drawstring(50, 0, Val);
  glcd.drawstring(62, 0, "  "); // show 2 empty spaces
  
}

else if(sensorValue < 10)
{ 
 glcd.drawstring(50, 0, Val);
  glcd.drawstring(56,0, "   "); // show 3 empty spaces
  
}
else glcd.drawstring(50, 0, Val);
glcd.display();
glcd.clear();



}