Ok so i have copied a simple IR sensor code and I am having issues. No matter what i do including unplugging the led i get a 1 reading. whats wrong? attached is a pic of my project and an ugly diagram.
Open the sketch found in File->Examples->IRremote->IRremoteInfo. If you upload and run this sketch it will give you all sorts of information on the ir library including the emitting pin. This is the pin that you should have the IR LED hooked up to. When I run IRremoteInfo on an UNO I see:
Ii also says one when i unplug the LED that's what surprises me. I will look into this more using the information you have all provided and see what i can do. Thanks so much.
I have the Duemilenove arduino and i have placed the LED + lead onto pin 3 from what i saw the is correct. And the detector is on Pin 2 witch also looked correct. Same result 1 all the time with or without the led on (unplugged) i also tried to block it. This is a simple thing what am i missing?
when i unplug the led lead from pin 3 it stays 1 until i plug it back in then it goes to 0. As long as i keep the detector covered it stays 0. Once i let the detector see the LED it goes back to 1. It will stay as 1 no mater what i cover up, but will go back to 0 if i unplug the led from pin 3 and plug it back in. Any thoughts?
Well it depends what you want to detect - IR is present all around you in nature - you and most of the thermal radiation emitted by objects near room temperature is infrared.
That why - to not confuse normal IR with generated IR - you use modulation at the emitter side and listen for that specific modulation at receiver side.
would be good to understand what's you equipment... is your receiver tailored to react only to 38KHz modulation? if it's a generic IR receiver then read again post #10.
The library you are using is meant to send data, with modulation and demodulation and coding with mark and spaces, and to receive data using the same principle (detect the modulation, detect the mark and spaces).
You are just reading your digital pin and not caring about the 38Khz modulation so your sensor tells you "there's IR in the air".
The library is meant also to drive the sender or the receiver but not both at the same time. You might run into timing challenges when trying to decode
Please - with 23 post you should by now know how to post code... Please correct your post above and add code tags around your code: [code]`` [color=blue]// your code is here[/color] ``[/code].
It should look like this:// your code is here
(Also press ctrl-T (PC) or cmd-T (Mac) in the IDE before copying to indent your code properly)
use clickable links for links, embed images into your post rather than attachments... that will make the life of those who are trying to help a bit easier and you are likely to get better and faster answers..
all this is documented at the top of the forum - please read those 3 pinned threads:
GoForSmoke:
It almost looks like you're trying to flash a led at 38KHz and then detect the flash with a digital read.
With digital read you get either 0 or 1. Is your sensor open to any near-IR sources including red leds?
I believe the sensor he has (VS1838B HX1838 Infrared Receiver) is filtering the modulated 38KHz signal and should hand over 0 or 1 appropriately as long as it's wired appropriately
Most users go for a small board with the proper R and C already wired.
J-M-L:
Please - with 23 post you should by now know how to post code... Please correct your post above and add code tags around your code: [code]`` [color=blue]// your code is here[/color] ``[/code].
It should look like this:// your code is here
(Also press ctrl-T (PC) or cmd-T (Mac) in the IDE before copying to indent your code properly)
use clickable links for links, embed images into your post rather than attachments... that will make the life of those who are trying to help a bit easier and you are likely to get better and faster answers..
all this is documented at the top of the forum - please read those 3 pinned threads:
You should read about how to setup a receiver by looking at the datasheet. here is one for the tsop382 for example.
Notice the RC circuit with the Receiver
I think i fixed the code up top so it has code[] at the front and end.
I did not use the rest of this circuit because every example i saw no one had the rest of the resisters and capacitors on there working examples. I will work on getting those items to see if it helps.
"It almost looks like you're trying to flash a led at 38KHz and then detect the flash with a digital read.
With digital read you get either 0 or 1. Is your sensor open to any near-IR sources including red leds?"
It is a detector that is suppose to detect at 38khz. And the counter part emitter pair. I thought the code i was using sent out a modulated 38khz IR beam and would see if the detector would detect that modulated IR beam. If it did it would send a 1 if not it would send a 0. Is that not what its doing?
On my arduino Duemilenove it should send a modulated signal on pin 3 and receive one on pin 2. Thats my understanding at least.