Reply To: I2C communication PCF8574AP

HomeForumsMonoBrick EV3 FirmwareI2C communication PCF8574APReply To: I2C communication PCF8574AP

#4889
Author Image
Bartłomiej Drozd
Participant

ok, i just tested it with LejOS and now i know, how to use it ;) i must write to register 0×16 byte array ;) and here is my test code

public static void Main (string[] args)
		{
			EventWaitHandle stopped = new ManualResetEvent (false);
			ButtonEvents btn = new ButtonEvents ();
			byte address = 0x70;
			byte[] data1 = new byte[1] { 0x05 };
			byte[] data0 = new byte[1] { 0x0A };
			LcdConsole.WriteLine ("hello world!");
			pcf pcf = new pcf (SensorPort.In1, address);
			btn.EscapePressed += () => {
				LcdConsole.WriteLine("stopped");
				stopped.Set ();
			};
			btn.LeftPressed += () => {
				pcf.WriteReg(0x16, data1);
				LcdConsole.WriteLine("write data1");
			};
			btn.RightPressed += () => {
				pcf.WriteReg(0x16, data0);
				LcdConsole.WriteLine("write data0");
			};
			btn.EnterPressed += () => {
				LcdConsole.WriteLine(BitConverter.ToString(pcf.ReadReg(16, 1)));
			};
			stopped.WaitOne ();
		}

thanks for help ;)

Posted in

Make a donation