code for IR sensor

Hello all!

i am trying to build an arduino device that contains a QRD1114 IR sensor, and when one runs their hand over it, will turn on a Infrared light attached to the device, which will thus turn on a projector. So basically i am trying to make a motion-sensing device using an IR sensor. I have succeeded in building it, however, the coding is very difficult and definetly not my forte...anyone care to help me with this? links and anything would be helpful!!

hm

r u trying to mimic an IR remote control?

maybe u can find a cool circuit here:
http://www.discovercircuits.com/ ?

-arne

In a way yes. Except its going to be motion-activated.
I should add...

I intend to turn on an AAXA pico2 projector...the projector itself does come with a IR remote control. So i figured, i can make that and turn it on! better yet, make it motion-activated!

ok

how do u know what "language" the projector understands?

-arne

hmmm...not sure about the language...

here is a link to the site: AAXA P2 Pico Projector - LCoS Based Hand-held Pocket Projector - LED Micro Projector

i guess the issue is more, i built the device with arduino and the output is a flashing IR light that will turn on the projector. Now, I'm not sure if the IR light is "compatible" enough to turn on the projector itself. If i could get a code and test it out, i might find out something or other

i c
so u need to "learn" the IR remote control language first...

i would do that like this:

  1. tell arduino to listen to the IR sensor as fast as possible and send the readings via USB... that would be about 5kHz...
  2. point the projector's IR remote control at the IR sensor and press the "play" button...
  3. look at arduino's readings and find the pattern...
  4. then u could try to produce the same pattern with ur IR light...

possibly ur IR light doesn't use the right IR "color"... :slight_smile:

most likely u dont want to open the projector's IR remote control and "press" the "play" button with a BJT via arduino?

-arne

well, first off, awesome suggestions!

now, i want the arduino to act as a replacement IR control for the projector....going further with this, i want it to be motion activated so that the step of"pressing buttons" would be eliminated. So, when someone walks by, a sensor will trigger the IR light to turn on which will signal the projector to turn on. So basically, its a motion-sensor projector!

Now as for the steps you told me about, i am not very code- savvy, so what "code" would i need to enter? ( i know thats kinda vague, i apologize!)

this would do a 1000 sample/sec "scan" of analog pin #0: wag tail

uint16_t last;

void setup() {
  analogReference(DEFAULT);
  Serial.begin(500000);
  last = micros();
}

void loop() {
  const uint16_t now = micros();
  if (now - last < 1000)
    return;
  last += 1000;
  const int v = analogRead(0);
  Serial.println(v);
}

the output would be in a human readable format...
u need to read from the serial device at 500kBaud...

-arne

ah cool

so, this will help me to determine the necessary "signal" for the projector?

possibly...
depends on the complexity of the language...
if it uses multiple IR colors, u can't learn it that way...

how will u connect ur IR sensor to pin #0?
maybe u will need a pullup resistor?
u can get one (20kR to 50kR) with "digitalWrite(14,HIGH);" in the setup() function...

-arne

gee truth be told, i am not so sure
:-/

i am very new at this...lol...

another idea i have been thinking about is actually taking apart the IR remote that comes with the projector and somehow manipulating that....would that be a possible thing to do?

if it uses multiple IR colors

I assume you mean the frequency of the electromagnet radiation. I am aware of only two frequencies that are used by IR diodes and they tend to overlap. I have never come across the use of the two in combination.

Or do you mean modulating frequency of the IR light. This is the rapid switching on an off of the IR at 30 to 40 KHz. This is modulated on top of the information of pulses that you would get from the program posted above. This is because the program above does not sample fast enough to 'see' the modulation.

The program is a good first step to see what pulses you need but you might also have to modulate the IR.

if it uses multiple IR colors

Yes you can remotely press the buttons using an opto isolator.
Opto-isolator - Wikipedia, it's the sort of thing people do when they indulge in "circuit bending".