LED displys 2 strange characters after each line of text

Hi,

This is my first arduino project so apologies for noob-ness. I’ve been trying to solve this problem for a while but can’t make any headway.

The project is a pedometer (using an accelerometer) which sends the steps to another arduino via RF24 wireless transceiver.
The code is a (messy) mashup of a few different tutorials, but works (apart from this LCD issue).

I’m using the lcd.print command which is showing two random characters after each line of text. I know its hooked up fine because the hello world example works fine.

I’ve attached the image showing the two characters.

Also, for some reason when the step count (bottom line) gets to 3 it stops counting and a lot of ??? appear on screen - this is probably a seperate issue I’ll deal with after I sort these random characters…

Any help would be appreciated.

Code is below:

//first calibrate on powering up the module
//a poscal function to calculate avg values of x , y , z and print them on serial
//turn on the LED on pin13 and turn it off after the calibration is completed

//in loop continually read the data and calculate total accerelation vector
//call stepdetect function
//print total number of steps on monitor
//if step occurs flash led 3 times

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <LiquidCrystal.h>

RF24 radio(7, 8); // CNS, CE

const byte address[6] = “00001”;

const int xpin=A2;
int ypin=A3;
int zpin=A4;

int powerpin=A0;
int gnd=A1;

float threshhold=40.0;

float xval[100]={0};
float yval[100]={0};
float zval[100]={0};
float xavg;
float yavg;
float zavg;

int steps,flag=0;

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 7, 5, 4, 3, 2);

void setup()
{
Serial.begin(9600);
pinMode(powerpin,OUTPUT);
pinMode(gnd,OUTPUT);
digitalWrite(powerpin,HIGH);
digitalWrite(gnd,LOW);
pinMode(13,OUTPUT);
calibrate();

radio.begin();
radio.openWritingPipe(address);
radio.setPALevel(RF24_PA_MIN);
radio.stopListening();

lcd.begin(16, 2);
lcd.print(“Goal is 10,000”);

void loop()
{int acc=0;
float totvect[100]={0};
float totave[100]={0};
//float sum1,sum2,sum3=0;
float xaccl[100]={0};
float yaccl[100]={0};
float zaccl[100]={0};
// float x,y,z;

for (int i=0;i<100;i++)
{
xaccl*=float(analogRead(xpin));*
delay(1);
//delay(100);
//x=sum1/100.0;
//Serial.println(xavg);
yaccl*=float(analogRead(ypin));*
delay(1);
//sum2=yaccl*+sum2;*
//y=sum2/100.0;
//Serial.println(yavg);
//delay(100);
zaccl*=float(analogRead(zpin));*
delay(1);
//sum3=zaccl*+sum3;*
//z=sum3/100;
totvect = sqrt(((xaccl-xavg)* (xaccl-xavg))+ ((yaccl - yavg)(yaccl - yavg)) + ((zval _- zavg)(zval - zavg)));
totave = (totvect + totvect[i-1]) / 2 ;
//acc=acc+totave*;_
_Serial.println(totave);
delay(200);
//cal steps*

if (totave*>threshhold && flag==0)*
{
* steps=steps+1;
flag=1;*_

}
else if (totave > threshhold && flag==1)
{
//do nothing
}
_ if (totave <threshhold && flag==1)
* {flag=0;}
Serial.println(’\n’);
Serial.print(“steps=”);
Serial.println(steps);*_

* radio.stopListening();*
* radio.write(&steps, sizeof(steps));*
{
lcd.setCursor(0,1);
lcd.print(steps);
}
}
//float tim=acc/100;
//Serial.println(tim);
delay(1000);
// stepcal(totave);

}
/*void stepcal(float arr[100])
*{ *
// int threshhold=80;
float jack=0;
//delay(100)
//Serial.println(xavg);
for (int i=0;i<100;i++)
{
jack=jack+arr*;*
}
float m=jack/100;
//Serial.println(yavg);
//delay(100);
//detect pushups or count for number of dumbles

//crossing the threshold and

//cross 20 in down and 80 in up

/*add one to counter and set a flag high to indicate it is above a threshhold value
if a flag is high and threshhold is crossed :do nothing }
if signal falls below threshhold set flag to -1 indicating it is blow threshhold
if (m>threshhold && flag==0)
{
* steps=steps+1;*
* flag=1;*
* Serial.println(’\n’);*
* Serial.print(“steps=”);*
* Serial.println(steps);*
}
else if (m > threshhold && flag==1)
{
//do nothing
}
* if (m <threshhold && flag==1)*
* {flag=0;}*
* Serial.println(’\n’);*
* Serial.print(“steps=”);*
* Serial.println(steps);*
} */

//calculate total accerelation vector
void calibrate()
{
* digitalWrite(13,HIGH);*

* float sum=0;*
* float sum1=0;*
* float sum2=0;*
for (int i=0;i<100;i++)
{
xval*=float(analogRead(xpin));*
sum=xval*+sum;*
}
delay(100);
xavg=sum/100.0;
Serial.println(xavg);
for (int j=0;j<100;j++)
{
xval[j]=float(analogRead(xpin));
sum1=xval[j]+sum1;
}
yavg=sum1/100.0;
Serial.println(yavg);
delay(100);
for (int i=0;i<100;i++)
{
zval*=float(analogRead(zpin));*
sum2=zval*+sum2;*
}
zavg=sum2/100.0;
delay(100);
Serial.println(zavg);
digitalWrite(13,LOW);
}

//counting the pushups

Might be because there are smileys and italics in your code. Compilers hate that.

Seriously, read the forum rules about how to post code properly so it is readable. The difference between good coders and those who just won't make it is the tendency to read the instructions and references first before diving in and writing.

I'm using the lcd.print command which is showing two random characters after each line of text.

Those two characters typically show up if you try to use lcd.println(...) which I don't see in your code. They are the result of trying to display the 'new line' codes which the LCD controller interprets as (undefined) custom characters.

I'm not going to try and interpret what you have displayed since who know what other things happened besides the appearance of the smiley and the italics. You can see if somehow you have sent some extraneous 'control' codes.

Don

Lol, your code looks like all messed up. Post a cleaner version, problem specific.

ive got your problem. in the coordinates for the radio instead of saying 7,8 it says 7, 8) with an emoji :wink: next time just write an 8

maybeifyouusedsomepunctuationwecouldfigureoutwhatyouhavesaidDon