Go Down

Topic: String and Array Confusion. (Read 1 time) previous topic - next topic

Nick Gammon

Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

bafill

#16
Apr 26, 2012, 03:47 am Last Edit: Apr 27, 2012, 03:20 am by bafill Reason: 1

Well show the code.


Hehehe, that would help wouldn't it.

Code: [Select]



Nick Gammon

Here:

Code: [Select]
// move onto next letter if required
  if (pixel >= 5)
    {
    pos++;
    if (displayThis [pos] == 0)  // back to start
      pos = 0; 
    }  // if done all 5 pixels


Once we get up to the 5th pixel we move onto the next letter, but someone (was that me?) forgot to go back to pixel 0. So add an extra line like this:

Code: [Select]
// move onto next letter if required
  if (pixel >= 5)
    {
    pixel = 0;
    pos++;
    if (displayThis [pos] == 0)  // back to start
      pos = 0; 
    }  // if done all 5 pixels
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

bafill

Its always something small like that.

Thanks so much for the help. I will keep you updated on my progress.

bafill

#19
Apr 26, 2012, 06:28 am Last Edit: Apr 27, 2012, 03:21 am by bafill Reason: 1
Grrrr this is getting crazy

Ok so we had some success with this code for displaying whatever is entered as plane text like hello world. But I am almost back to square 1. The time is not displaying on my POV. Maybe if I let you know what components I am using. The LED setup is pretty straight forward, I am using 8 red LED's with 220 ohm resistors feeding off of the UNO's 0-7 digital outputs (PORTD). I have an Adafruit RS1307 breakout board RTC on analog pins A2-A5, A2 and A3 are providing 5 volts and ground for the RTC board.

I was thinking it had to do with the sprintf() towards the end of the loop that shows, "sprintf (displayThis, "%02i:%02i:%02i", Hrs, Mins, Sec);"
if I change that to just "sprintf(displayThis, "hello world");" it works. But when I change it back to the original one to display the time it does not.  

And here is my code again:

Code: [Select]



Nick Gammon

Code: [Select]
char displayThis [40] = { 0 };

...
 
  char displayThis [20];
  sprintf (displayThis, "%02i:%02i:%02i", Hrs, Mins, Sec);


You have two displayThis variables. You are putting the time in one of them, and showing the contents of the other one.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

bafill

Ok Nick

I removed the second char displayThis[20] and guess what??? IT WORKED!!!!!!!!!!!!!!

I have a POV clock!!!! I am so happy it feels like I won the lottery.

Now all I have to do is work out the display spacing and the motor control circuit but that is the easy part.

Thank you so much.
Phillip B.

Go Up