Issues when using an IR remote and i2c

Hi, first off my apologies if I selected the wrong category...

I basically made a whole project that contains a few things like an i2c, IR sensor and IR remote receiver. My code works the whole time except when I press on any button of the remote. This freezes my arduino and the serial monitor stops working either until I reset the arduino. After a few hours of trying I've found that if I remove the i2c part of my code (removing Wire.begin(); alone is apparently enough), the IR remote sensor works so it really has something to do between the IR remote and the i2C. Any clue how to fix this?
the i2c is PCF8574, the IR remote sensor is VS 1838B and I'm using a Leonardo ETH
Thank you a lot for the help!!

Might be some help in this thread.

Restrict your I2C requests to 1 byte in loop(), no while().

Hi thank you both for your replies.

I checked through that post and tried various times but no progress. It gave me better insight though so thanks!

I'm not asking for any data from my i2c but rather only sending data.

//i2c

  if (IRcounter == 0) sevwaarde = B00111111;
  if (IRcounter == 1) sevwaarde = B00001001;
  if (IRcounter == 2) sevwaarde = B01011110;
  if (IRcounter == 3) sevwaarde = B01011011;
  if (IRcounter == 4) sevwaarde = B01101001;
  if (IRcounter == 5) sevwaarde = B01110011;
  if (IRcounter == 6) sevwaarde = B01110111;

  Wire.beginTransmission(sevseg);
  Wire.write(sevwaarde);
  Wire.endTransmission();

The i2c only shows some number from 0-6 depending on how many times something got in front of an infrared sensor.

I made some progress! I added an interrupt that happens when I press on any button of the remote. and added a delay to the void loop (). the code works but is very unstable. The program can still crash and the arduino somehow doesn't read all my inputs so I usually have to time my button clicks perfectly or something. I don't really get it...

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.