SerialLCD and SoftwareSerial (slcd.print(val5,byte).

I have this program, that I want to print the bytes to, LCD. From (0 to 253). But I don't how to make the code send the bytes to the lcd. Or when I compiling my program it, it tell me (expected primary-expression before
')' token.

Here is my code.

#include <SerialLCD.h>
#include <SoftwareSerial.h>

int analogValue2, analogValue5, val2, val5;
SerialLCD slcd(11,12);
void setup()
{
 slcd.begin();
  // Print a message to the LCD.
  slcd.print("hello, world!");
Serial.begin(19200);
}

void loop()
{
// read analog input
analogValue2 = analogRead(0);
analogValue5 = analogRead(4);

// remap values

val2 = map(analogValue2, 0, 1023, 0, 253);  // 254 and 255 for SYNC
val5 = map(analogValue5, 0, 1023, 0, 253);

Serial.write(254); //SYNC char
Serial.write(val2);
Serial.write(val5);
delay(150);

 slcd.setCursor(0, 1);
 
 slcd.print(val2,byte);
 
  slcd.setCursor(7, 1);
 
 slcd.print(val5,byte);


}

I'm not sure what the problem is. Do you want to print the numeric value of val2 and val5 to the screen? If yes, then use slcd.print(val2);.
slcd.print(val2,byte); is wrong, you don't need to specify the type (you can specify the base such as decimal, hexadecimal, octal, or binary).
You can't pass a type as a parameter in C/C++ anyway.

Yes I want to print it numeric value. I tried this code and no, go.
It print to my serial Monitor on my Arduino. As I move the pot it goes from 0 to 253, Ok.

#include <SerialLCD.h>
#include <SoftwareSerial.h>

int analogValue2, analogValue5, val2, val5;
SerialLCD slcd(11,12);
void setup()
{
 slcd.begin();
  // Print a message to the LCD.
  slcd.print("hello, world!");
Serial.begin(19200);
}

void loop()
{
// read analog input
analogValue2 = analogRead(0);
analogValue5 = analogRead(4);

// remap values

val2 = map(analogValue2, 0, 1023, 0, 253);  // 254 and 255 for SYNC
val5 = map(analogValue5, 0, 1023, 0, 253);

Serial.write(254); //SYNC char
Serial.write(val2);
Serial.write(val5);
delay(150);

 slcd.setCursor(0, 1);
 
 slcd.print(val2,DEC);
 
  slcd.setCursor(7, 1);
 
 slcd.print(val5,DEC);


}

What do you see on the screen?

The screen is telling me. As I turn the pot
It goes (one byte at A time) . then , then ? then !
then ' and so on.

I would like it to print out 0 to 253.
slcd.print(val2);
slcd.print(val5);

I'd say that the problem is probably with the code your library uses. I don't see a reason for print() to fail in printing an int.

Here is the web page where I found the
Code

http://www.seeedstudio.com/wiki/index.php?title=Grove_-_Serial_LCD_V1.0

Do you think that I would have to use code
like this to, set up the byte. ( slcd.print(val2)

slcd.print(data); // Data can be any text
slcd.print(data,BASE); // BASE can be BIN, DEC, OCT or HEX
slcd.print(float_data,2);//show float data,Decimal digits(1-3)

I can't really add any more information, I don't see why it would print the character instead of the value.
Make sure that val2 and val5 are not declared as 'byte' or 'uint8_t', etc.

Hi

Is there anyone that can tell me why this program will tell the Pot Value and the other program, tells me.
Only one letter at A time. Like this a,b,c,d,f,g,h,i,j,k,l.m.n.o.p.q.u.s.t and so on, as you turn the pot.

Working Program.....

#include <Wire.h>  
#include <LCD.h>  
#include <LiquidCrystal_I2C.h>  
  
#define LCD_I2C_ADDR    0x27  // Define I2C Address where the PCF8574A is  
#define BACKLIGHT     3  
#define LCD_EN  2  
#define LCD_RW  1  
#define LCD_RS  0  
#define LCD_D4  4  
#define LCD_D5  5  
#define LCD_D6  6  
#define LCD_D7  7  
  
int potPin = 0;    // select the input pin for the potentiometer  
  
LiquidCrystal_I2C       lcd(LCD_I2C_ADDR,LCD_EN,LCD_RW,LCD_RS,LCD_D4,LCD_D5,LCD_D6,LCD_D7);  
  
void setup()  
{  
lcd.begin (16,2);  
  
lcd.setBacklightPin(BACKLIGHT,POSITIVE); // init the backlight  
lcd.setBacklight(HIGH); // Backlight on  
lcd.clear(); // Clear the lcd  
}  
  
void loop()  
{  
  
int potVal = analogRead(potPin);    // read the value from the sensor  
//lcd.clear();  
lcd.home ();                  // go home  
lcd.print("Pot value");  
String value = potVal + "   ";  
lcd.setCursor ( 0, 1 );        // go to the next line  
lcd.print(potVal);  
// Print 3 spaces to "clear the line"  
lcd.print("   ");  
//delay(100); // Wait 0.1 seconds before reading again  
}

Not Working Program, but if I read the Serial Monitor on my Arduino it will read 0 to 1023. As I turn the Pot.
(Serial.print(potVal);

int potPin = 0;



#include "SerialLCD.h"
#include <SoftwareSerial.h> //this is a must

// initialize the library
SerialLCD slcd(11,12);//this is a must, assign soft serial pins

void setup() {
  // set up
  slcd.begin();
 slcd.backlight();
 Serial.begin(9600); 
}

void loop()  
{  
  
int potVal = analogRead(potPin);    // read the value from the sensor  
//lcd.clear();  
slcd.home ();                  // go home  
slcd.print("Pot value");  
String value = potVal + "   ";  
slcd.setCursor ( 0, 1 );
slcd.print(potVal);  
// Print 3 spaces to "clear the line"  
slcd.print("   ");  

                      
 Serial.print(potVal);      
    
delay(100);
}

I think you are getting burned by crappy library software.
It looks likes their library is overloading the Print class functions with their own functions,
so when you try to call print(int val) you are not getting the Print class version of the function
but theirs instead which looks like it falls back to a byte output.

I'd go in and comment out all their print functions in their header and .cpp code
and use the real Print class which is what is being used on the LiquidCrystal and Serial libraries.

Since this library uses SoftSerial and SoftSerial inherits the Stream class which inherits the Print class, all you need
to do to get the real Print class routines is to get rid of their print() functions.

Use something like

#ifdef notdef
code that you want to eliminate
#endif

They are all grouped together in their files:
SerialLCD.cpp
SerialLCD.h

So it should be pretty easy.

--- bill