Pages: 1 [2]   Go Down
Author Topic: String and Array Confusion.  (Read 1627 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18800
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well show the code.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well show the code.

Hehehe, that would help wouldn't it.

Code:

« Last Edit: April 26, 2012, 08:20:52 pm by bafill » Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18800
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Here:

Code:
// 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:
// 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
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Its always something small like that.

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

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

« Last Edit: April 26, 2012, 08:21:50 pm by bafill » Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18800
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: 1 [2]   Go Up
Jump to: