IR sensors facing to each other

Hi, can please someone help, I´m building H-pattern shifter and I´m using code downloaded from internet which works well, I was using it with mechanical switches, but I´m trying to upgrade it to contactless system using IR sensors, I´m using seven FC-51 sensor boards, I installed row of diodes on one side of the shifter (Gear 2,4,6,R) And it works flawlessly, configured to turn on in distance around 1 cm just like I want it , no issues at all until I added oposite side of shifter diodes (Gear 1,3,5) which are now facing directly to first row, distance is around 5cm from each other, and now all my diodes are turned on all the time, I tried to switch diodes , so reciver is not facing to transmitter, but I discovered no difference, I tried to move it more far away form the first row, or lower it below , but even 4 cm below first row it´s still interfering... radius where it interfere is pretty big (20cm from each in the same level still turned on), I´m pretty new to coding , It´s some way how to make it work with some code changes, or it´s impossible that two IR sensors can work without interfering when facing to each other ?

thanks for any advice or solution

I´m using Arduino Pro micro

#include <Joystick.h>
Joystick_ Joystick;

int gear1 = 3; // first gear set to pin 3
int gear2 = 4; // second gear set to pin 4
int gear3 = 5; // third gear set to pin 5
int gear4 = 6; // fourth gear set to pin 6
int gear5 = 7; // fifth gear set to pin 7
int gear6 = 8; // eight gear set to pin 8
int gearR = 9; // nineth gear set to pin 9


void setup() {

pinMode(gear1, OUTPUT); 
digitalWrite(gear1, HIGH);

pinMode(gear2, OUTPUT); 
digitalWrite(gear2, HIGH);

pinMode(gear3, OUTPUT); 
digitalWrite(gear3, HIGH); 

pinMode(gear4, OUTPUT); 
digitalWrite(gear4, HIGH);

pinMode(gear5, OUTPUT); 
digitalWrite(gear5, HIGH); 

pinMode(gear6, OUTPUT); 
digitalWrite(gear6, HIGH); 

pinMode(gearR, OUTPUT);
digitalWrite(gearR, HIGH); 


pinMode(3, INPUT);
pinMode(4, INPUT);
pinMode(5, INPUT);
pinMode(6, INPUT);
pinMode(7, INPUT);
pinMode(8, INPUT);
pinMode(9, INPUT);



Joystick.begin(); 

 Serial.begin(115200);
}

void loop() {

if
(digitalRead(gear1) == 0)
{
Joystick.setButton(0, 1);
}
if (digitalRead(gear1) == 1)
{
Joystick.setButton(0, 0); 
}


if
(digitalRead(gear2) == 0)
{
Joystick.setButton(1, 1);
}
if (digitalRead(gear2) == 1)
{
Joystick.setButton(1, 0); 
}


if
(digitalRead(gear3) == 0)
{
Joystick.setButton(2, 1);
}
if (digitalRead(gear3) == 1)
{
Joystick.setButton(2, 0); 
}


if
(digitalRead(gear4) == 0)
{
Joystick.setButton(3, 1);
}
if (digitalRead(gear4) == 1)
{
Joystick.setButton(3, 0); 
}


if
(digitalRead(gear5) == 0)
{
Joystick.setButton(4, 1);
}
if (digitalRead(gear5) == 1)
{
Joystick.setButton(4, 0); 
}


if
(digitalRead(gear6) == 0)
{
Joystick.setButton(5, 1);
}
if (digitalRead(gear6) == 1)
{
Joystick.setButton(5, 0); 
}


if
(digitalRead(gearR) == 0)
{
Joystick.setButton(6, 1);
}
if (digitalRead(gearR) == 1)
{
Joystick.setButton(6, 0); 
}
}

You could put both the sensors and leds in tubes to limit their field view and stop them triggering their neighbours .
Couldn’t you just use the one set of leds/sensors and something else to detect which side of the gate the selector is on

1 Like

I have it pretty enclosed, the neighbours from one row are not interfering at all, just from oposite side, and even Reverse gear which is not neighbouring directly diodes from oposite direction is catching signal somehow,

one set of diodes will not do the trick , sensors alone have pretty small radius to the sides, thats the wierdest thing, when they are face to face signal is amplified x many times to the sides and lenght of signal.... alone they are not capable to catch signal when obstacle in more than 5cm away form diodes, when facing to each other they are able to switch on in 30cm


Any possibility of mounting a magnet on the shifter and sensing positions with Hall effect switches?

It was my first option to go with, but unfortunately I dont have much space below black board from the picture, I was trying to make it smaller as posible plus its really imposible to find magnet to fit my setup (shape, size, right magnetization type)...

Isn´t any code change solution ? changing frequency of every transmiter or something like that ?

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