I have revised all the code so it should work better. It also contains an
LCD display, but no serial communication. Although I mentioned that the
project was for the arduino mega, I forgot to say that it only works with
it. I finnished the last post with only 8 characters remaining, so I could
not include all the details Iwanted to.
The LED address will look something like TRL or BFR. These are simple to
understand: The first letter denotes the level - top or bottom. The second
letter denotes the position - front or rear. The third letter denotes the
side - left or right.
A potentiometer could be connected to the analog pin A0 to control the
brightness, or a number can be put in when you upload the program.
All the LEDs are connected to PWM pins to allow this.
Those familliar with the liquidCrystal library will know that the initialization
goes LiquidCrystal(rs, enable, d4, d5, d6, d7). In the new code we initialize
it with: LiquidCrystal lcd(53, 51, 41, 39, 33, 31). So, RS, LCD pin
4, goes to digital pin 53, enable, LCD pin 6, goes to digital pin 51,
d4, LCD pin 11, goes to pin 41, d5, lcd pin 12, goes to pin 39, d6,
LCD pin 13, goes to digital pin 33 and d7, lcd pin 14, goes to digital
pin 31. The LCD is then set up as shown in the following link, only
with the new pin arrangement.
The new code would not fit on this post, so it is on the next one.
To get liquid crystal to work, you need the liquid crystal library.
When I import it, it comes up with the two libraries you see. If
you try it and it does not work, delete the libraries at the top of
the code and go into sketck>>import library>>liquidCrystal.
It shuld work.