LCD display count values (HELP!)

Hello to all,

I am working on a project that uses the ky-008 sensors and receivers. I have them wired up and want them to count and display values on my lcd.

I am having 2 problems at the moment,
First my count only goes to 9, and displays letters a, b, c, d, .... for ever count value.
Second, i can only get one counter working at a time. I believe its in the structure of my if statement, but i am still new and just cant seem to understand why. Any help advice or guidance is appreciated.
code posted below:

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
int Laser1 = 6;
int Detector1 = 7;
int Laser2 = 8;
int Detector2= 9;
char x=0;
char y=0;

void setup()
{
// put your setup code here, to run once:

Serial.begin (9600);
lcd.begin(16,2);
pinMode(Laser1, OUTPUT);
pinMode(Laser2, OUTPUT);
pinMode(Detector1, INPUT);
pinMode(Detector2, INPUT);
}

void loop() {
lcd.clear();
digitalWrite(Laser1, HIGH);
digitalWrite(Laser2, HIGH);

int val1 = digitalRead(Detector1);
delay(200);

if (val1==0)
{x++;
lcd.setCursor(0,0);
lcd.print("Quarters");
delay(2000);
lcd.setCursor(0,1);
itoa(x, "outputx",33);
lcd.print("outputx");
delay(2000);
Serial.println("outputx");}
else
{x=x;
}
int val2 = digitalRead(Detector1);
delay(200);
if (val2==0)
{y++;
lcd.setCursor(0,0);
lcd.print("Dimes");
delay(2000);
lcd.setCursor(0,1);
itoa(y, "outputy",33);
lcd.print("outputy");
delay(2000);
Serial.println("outputy");}
else
{y=y;}}

With this correction i am able to count with 2 line break sensors, they count until 9, and then the begin to count in letters.

int val2 = digitalRead(Detector2);
delay(200);
if (val2==0)

Can anyone tell my why the count would display as a letter after any of the 3 sensors count past 9?
3 x ky-008 sensor and reciever

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
int Laser1 = 6;
int Detector1 = 7;
int Laser2 = 8;
int Detector2= 9;
int Laser3 = 11;
int Detector3= 10;
char x=0;
char y=0;
char z=0;

void setup()
{
Serial.begin (9600);
lcd.begin(16,2);
pinMode(Laser1, OUTPUT);
pinMode(Laser2, OUTPUT);
pinMode(Detector1, INPUT);
pinMode(Detector2, INPUT);
pinMode(Laser3, OUTPUT);
pinMode(Detector3, INPUT);
}

void loop()
{lcd.clear();
digitalWrite(Laser1, HIGH);
digitalWrite(Laser2, HIGH);
digitalWrite(Laser3, HIGH);

int val1 = digitalRead(Detector1);
delay(5);
if (val1==0)
{x++;
lcd.setCursor(0,0);
lcd.print("Quarters");
delay(450);
lcd.setCursor(0,1);
itoa(x, "outputx",33);
lcd.print("outputx");
delay(450);
Serial.println("outputx");}
else
{x=x;}

lcd.clear();
int val2 = digitalRead(Detector2);
delay(5);
if (val2==0)
{y++;
lcd.setCursor(0,0);
lcd.print("Dimes");
delay(450);
lcd.setCursor(0,1);
itoa(y, "outputy",33);
lcd.print("outputy");
delay(450);
Serial.println("outputy");}
else
{y=y;}

int val3 = digitalRead(Detector3);
delay(5);
if (val3==0)
{z++;
lcd.setCursor(0,0);
lcd.print("Pennies");
delay(450);
lcd.setCursor(0,1);
itoa(z, "outputz",33);
lcd.print("outputz");
delay(450);
Serial.println("outputz");}
else
{z=z;}}

Because you are printing out the numbers base 33.

Docs for itoa are here.

Is this a duplicate of your other post? Do you want any help to also be duplicated to both threads, or should you ask the mods to remove one of the posts?

else
  {z=z;}

WTF?

Why are you using char to hold a counter? Use byte! If you intent to count beyond 255, use int.

PaulS:
Why are you using char to hold a counter? Use byte! If you intent to count beyond 255, use int.

x and y are cartesian coordinates. They can be negative. Oh, wait, they're dimes and quarters. Um, what does this thing do exactly? :slight_smile:

Um, what does this thing do exactly?

Isn't that clear? It doesn't work. 8)