Search code examples
c#serial-portserial-communication

c# console application sending commands to LCD Screen


I have a small LCD screen. At the moment I can write text to it, and commands such as clear screen etc. These commands came with the user manual, and they have been working fine, however I want to be able to change colour of the LCD screen.

All the commands for changing colour have (0x255) in them which is causing a problem. An error occurs saying 'Constant value 597 cannot be converted to byte'.

The commands have to be send as hex.

Here is the code I have been using:

        byte[] bytesToSend = { 0xFE, 0xD0, 0x0, 0x0, 0x255 };
        port.Write(bytesToSend, 0, bytesToSend.Length);

Is there any way around this? Thanks, Lucy


Solution

  • You mean "0xFF" or "255" decimal, not "0x255". That is not within the range of bytes.