Pages: 1 [2] 3   Go Down
Author Topic: Concatenate Serial.print() values  (Read 6582 times)
0 Members and 2 Guests are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 28
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 240
Posts: 24465
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Was that the sprintf with the single quotes?
If not, could you repost?
Logged

"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.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 28
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 240
Posts: 24465
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you won't repost, I'll assume the single quotes are still there.
Did you read reply #14?
« Last Edit: June 26, 2010, 05:30:53 pm by AWOL » Logged

"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.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 28
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 240
Posts: 24465
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, you do.
Logged

"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.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 28
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 28
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Knivsta,Sweden
Offline Offline
Sr. Member
****
Karma: 0
Posts: 274
Low level's cool
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
char xValHex[4];
char yValHex[4];

Make those 5 bytes long, so they'll have room for the terminating zero-byte.
« Last Edit: July 04, 2010, 05:23:06 pm by drhex » Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 240
Posts: 24465
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did your mom ever tell you that it's useful if you post your code, 'cos very few of us are psychic?
Logged

"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.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 28
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
#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
}
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 28
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 240
Posts: 24465
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"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.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 28
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 28
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: 1 [2] 3   Go Up
Jump to: