Can I include both IR Emitter & IR Receiver in 1 board?

Hello,



I just started learning the basics and I am right now stuck to continue. I just get a constant ‘0’ for the Receiver and a ‘1’ for the Emitter. [Check down for code]



I have a classical Arduino UNO board, with an Arduino Shield V2 to be able to connect the Infrared Emitter and the Infrared Receiver. I literally find no proper resources on how to make them work in a single board (I’ve seen just examples with 2), so my first Q’s is: Am I doing wrong by trying to make it work in a single board?.



After that, which it could also be where I am really stuck on here is that I am trying to make it work through the MatLAB program. Simply I find it easier to start with, and as I have to lately send the Block action from the IR’s to a solenoid, in the same circuit, which btw that part already works, so I need your help to finish this small project!



MatLAB_CODE:

[code]
a = arduino(‘COM11’ , ‘Uno’);

for i = 1:10
%Read values of Emitter and Receiver
infrared_Emitter = readDigitalPin(a, ‘D2’)
infrared_Receiver = readDigitalPin(a, ‘D4’)

%once they both have the same value, it means its getting detected (is it?)
 if(infrared_Emitter == infrared_Receiver)   
   writeDigitalPin(a, 'D09', 1) 
end

end
[/code]



Advices are also gladly welcome,
David

Hello,

the demo of seeed wiki used them on two board, so if you want to install both of them on one board, you need to write code yourself.

And The problem is that readDigitalPin()only read the high/low of the pin, and the IR Emitter&Recivers translate a data package a time, I do not suggest you complete your project with matlab, or you need to rewrite the whole library.