Go Down

Topic: Device ID and direction detection in swarm intelligence using IR communication? (Read 986 times) previous topic - next topic

pidurkar_paras

I am using a arduino uno connected with 4 HS0038 IR sensor on 4 corners of arduino .each ir sensor is accompanied with a ir led which will be transmitting a specified code in 4 directions the code will be unique for each module (refer figure).the arduino module can receive the codes from nearby module with the help of the ir sensor and will tell its own presence to the nearby module with the help of ir led. but all 4 sensors on the module are picking up the code even they are far apart. I can't understand what i have written wrong in the code and why the sensors are picking up the data even when i try to isolate that particular sensor.


code
#include <IRremote.h>
int RECV_PIN_T =8;
int RECV_PIN_L=9;
int RECV_PIN_B=10;
int RECV_PIN_R=11;
int IRledPin = 13;
IRrecv irrecv1(RECV_PIN_T);
IRrecv irrecv2(RECV_PIN_L);
IRrecv irrecv3(RECV_PIN_B);
IRrecv irrecv4(RECV_PIN_R);
//IRsend irsend;

decode_results results1;
decode_results results2;
decode_results results3;
decode_results results4;

void setup()
{

pinMode(RECV_PIN_L, OUTPUT);
pinMode(RECV_PIN_T, OUTPUT);
pinMode(RECV_PIN_B, OUTPUT);
pinMode(RECV_PIN_R,OUTPUT);


Serial.begin(115200);
irrecv1.enableIRIn(); //Enabled the ir sensor
irrecv2.enableIRIn();
irrecv3.enableIRIn();
irrecv4.enableIRIn();


Serial.println("Getting IR data");
}

void loop() {

if (irrecv1.decode(&results1)) {
int value1=analogRead(RECV_PIN_T);
unsigned int value = results1.value;
if(value1>0&&value<10)
{
Serial.print("TOP ");

Serial.println(value);
delay(800);
}
irrecv1.resume();
}
//delay(5000);
if (irrecv2.decode(&results2)) {
int value2=analogRead(RECV_PIN_L);
unsigned int value = results2.value;
if(value2>0/*&&value<10*/)
{
Serial.print("LEFT ");
Serial.println(value);
}
delay(800);

irrecv2.resume();
}
//delay(4000);

/* if (irrecv3.decode(&results)) {
int value3=analogRead(RECV_PIN_B);
unsigned int value = results.value;

//if(value3>0&&value<60)
Serial.print("Bottom");
Serial.println(value);
delay(200);

irrecv3.resume(); }*/


}


Paul_KD7HB

Do you have shielding tubes over each IR LED and IR receiver?

Paul

Go Up