Go Down

Topic: Concatenate Serial.print() values (Read 9674 times) previous topic - next topic

nerdboy64

I deleted the bad bit of code, but it still gave me the same error. In fact, the line it highlighted was not the Serial.print(), but the one with the sprintf(). Anyway, I am bothering you all once again to see if the great thinkers of Arduino can help out.

AWOL

Was that the sprintf with the single quotes?
If not, could you repost?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

nerdboy64

The code is the same as the last time I posted my whole program, except the 'BYTE' Serial.print(xValHex,BYTE) and Serial.print(yValHex,BYTE) has been deleted.

AWOL

#18
Jun 27, 2010, 12:23 am Last Edit: Jun 27, 2010, 12:30 am by AWOL Reason: 1
If you won't repost, I'll assume the single quotes are still there.
Did you read reply #14?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

nerdboy64

Yes, the single quotes are still there. I assume that I need to chenge them to double quotes?

AWOL

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

nerdboy64

Thanks! For once the compiler didn't come up with an error. Now I can finally begin the real programming. :)

nerdboy64

As my mom might have said, "Don't count your chickens before they hatch." I tried out the code and, even though there was no error detected by the compiler, nothing appeared on the screen of the LCD. Any suggestions?

drhex

#23
Jul 04, 2010, 09:08 pm Last Edit: Jul 05, 2010, 12:23 am by drhex Reason: 1
Code: [Select]
char xValHex[4];
char yValHex[4];


Make those 5 bytes long, so they'll have room for the terminating zero-byte.

AWOL

Did your mom ever tell you that it's useful if you post your code, 'cos very few of us are psychic?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

nerdboy64

Here's my code: (After I took drhex's advice)

Code: [Select]
#define TO_HEX(x)  (((x) > 10) ? (x) - 10 + 'A' : (x) + '0')
byte xVal = 64;
byte yVal = 32;
char xValHex[5];
char yValHex[5];

void setup(){
sprintf(yValHex,"0x%c%c", TO_HEX (yVal >> 4), TO_HEX (yVal & 15));
sprintf(xValHex,"0x%c%c", TO_HEX (xVal >> 4), TO_HEX (xVal & 15));
Serial.begin(9600);
Serial.print(0x7C,BYTE);//cmd
Serial.print(0x02,BYTE);//backlight
Serial.print(0x19,BYTE);//set to 25
}
void loop(){
Serial.print(0x7C,BYTE);//cmd
Serial.print(0x03,BYTE);//circle
Serial.print(xValHex);//x-coord
Serial.print(yValHex);//y-coord
Serial.print(0x0A,BYTE);//radius ten
Serial.print(0x01,BYTE);//draw
}

nerdboy64

Hello? Anybody got some advice? I posted my code.

AWOL

You're the one with the hardware - what steps have you taken to debug?

I'd be inclined to use the serial monitor rather than unproven LCD hardware, at least until you've proven that the messages you need are ebing sent and received, at the correct rate and in the expected format.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

nerdboy64

I tried the serial monitor and I think I've found the problem. When It sends the information that sets the backlight value, it comes up on the serial monitor as funky symbols, but when It sends the hex information, it comes up as readable letters. If I am correct (which I'm probably not) it's the result of the "BYTE" format being removed from the Serial.print() command. Any suggestions? (Honestly, I haven't done much to debug. I only checked the connections and ran it through the compiler a couple times.) In case you're wondering, my code is still the same.

nerdboy64

Does anyone have some advice? I'm still confused!

Go Up