2012-02-29, 01:40 PM
Your second while loop goes out of bounds.
b <= arraymax lets b grow to 10, and accessing array_distance[10] causes a problem.
Make your loops like this:
while (i < arraymax)
For all loops, that way you never run into indexing issues.
b <= arraymax lets b grow to 10, and accessing array_distance[10] causes a problem.
Make your loops like this:
while (i < arraymax)
For all loops, that way you never run into indexing issues.
Code:
for(int i = 0; i < arraymax; i++)
{
array_distance[i] = distance;
Wait(50);
}
for(i = 0; i < arraymax; i++)
{
NumOut(i * 4, LCD_LINE1, array_distance[i]); //printing array on LCD screen, parameters NumOut(x,y,value).
}