CAN ANYONE teach ME HOW TO SIMPLIFY THIS CODE? it is very messy. How if I have 100 parking lots.
I have no idea at all.
1 = available
0 = unavailable
I know how to declare the array
but I dont know how to insert it.
int8 x;
int8 y;
int8 plav[4];
One way to implement this cleanly would be to use a switch/case statement. Take a0, a1, a2 and combine them into one number. I think your naming convention is backwards of normal (a0 is typically the lowest precision bit, thus representing the 1's position... a1 would represent 2', a2 would represent 4's, etc), so this will look a little different than I've typically seen it.
number = 4*a0 + 2*a1 + a0. This will convert your three bits into a number ranging from 0 to 7 (2^3 = 8 binary combinations). Then use code like the following (syntax specific to your device... look in the compiler's help pages for examples).
Code:
my_number = 4*a0 + 2*a1 + a0; //converts three bits to a single unsigned integer value from 0-7
switch(my_number)
{
case 2, 4: lcd_print(".....2/3");
case 3, 5, 6: lcd_print(".....1/3");
default; //default handles all other cases left undefined (e.g. 0, 1 and 7)
}