LCD I2C hd44780 .NET 8 c# code to display a text doesnt work

40 Views Asked by At

I have LCD I2C hd44780 connected to raspberry pi4. I wanted to display something using C# in .NET 8 My current code looks like that:

using System;
using System.Device.I2c;
using Iot.Device.CharacterLcd;
using System.Threading;

class Program
{
    static void Main()
    {
        const int i2cAddress = 0x27;

        using I2cDevice i2cDevice = I2cDevice.Create(new I2cConnectionSettings(1, i2cAddress));
        using Lcd1602 lcd = new Lcd1602(i2cDevice);

        lcd.Clear();
        lcd.Write("Hello, World!");

        
        Thread.Sleep(5000); 

        
        lcd.Clear();
    }
}

when i run this there is no error and no any informations in my terminal but my lcd goes dark. I mean it turns off light inside (I am sorry, I dont know how it is called). Also its worth to mention that i have python code that works with no issues at all.

from rpi_lcd import LCD
import sys

display=LCD()

try:
    while True:

        display.text(sys.argv[1],1)
        display.text(sys.argv[2],2)
    
        print(sys.argv)
                
except KeyboardInterrupt:
    print("cleaning up")
    display.lcd_clear()

I think i tried everything I was able to. Used some AI, looked at many forums tried diffrent libraries. I dont know, maybe someone will help. Thanks

0

There are 0 best solutions below