Go Down

Topic: First time playing with an IR sensor. (Read 2626 times) previous topic - next topic

Ampix0

Well Im pretty much attacking this kit I bought lol. I am kind of just plugging things in and hoping it does something honestly. I just shoved a IR sensor (VS1838B) on my board ran the 5v line to it and a 220 ohm resistor (only because I saw someone use that for an LED on a tutorial lol. No clue what I am really doing).

So I am just reading the input. Curiously just being on gives the value 123-127. While holding down any button on the remote I am using you get 13.

I assumed that maybe the sensor becomes more resistant when IR light is present and that 125ish is what ambient light does to it. I decided to take out the resistor to someone test that theory (yes I know that's bad) oddly I still got 125 and 13 on a button press.

So I have more experimenting to do I guess. :P

Code: [Select]
int ir = A0;
int data = 0;

void setup() {
  Serial.begin(9600);
  }
 
void loop() {
  data = analogRead(ir);
  if (data != 125) {
  Serial.println(data);
  }
  else {}
 
  delay(100);
}

seadanzig

Hi there newbie here too.

Just looking through your code

You have data is 0

Then if data is not equal to 125
Then print data.
Take out if statement.

Then use println(ir);
That is what you need to send
Hope tbst helps

Ampix0


Hi there newbie here too.

Just looking through your code

You have data is 0

Then if data is not equal to 125
Then print data.
Take out if statement.

Then use println(ir);
That is what you need to send
Hope tbst helps


Sorry I dont understand. Data is only initialized as "0", that code doesn't actually effect anything. I have the if statement there to filter out the 125s that it gets for just being on. (make it easier to read the log).
Also printing IR would result A0. You need to analog read A0 into memory first, which is why we have data.

seadanzig

my bad just reread your code again I'm using my phone with a cracked screen. Have you looked at the data sheet for the ir receiver

Ampix0


my bad just reread your code again I'm using my phone with a cracked screen. Have you looked at the data sheet for the ir receiver


Not that I really know how to read one, I found on in Japanese lol.

I just found this though, though it seems to be getting a different but similar result to me. Every button on the remote just puts the same number in the monitor.
http://www.arcfn.com/2009/08/multi-protocol-infrared-remote-library.html

Far-seeker


Well Im pretty much attacking this kit I bought lol. I am kind of just plugging things in and hoping it does something honestly. I just shoved a IR sensor (VS1838B) on my board ran the 5v line to it and a 220 ohm resistor (only because I saw someone use that for an LED on a tutorial lol. No clue what I am really doing).


Unless you want to spend a lot of extra time, a non-trivial amount of money replacing broken parts, and occasionally cause avoidable personal danger to yourself; this is a habit you need to break (at least while working with electronics).  Seriously, you should have a basic understanding of how a part functions and what it's rated for both normal operation and the worst conditions it can withstand.  The ratings are found in the part's datasheets, sometimes along with additional useful information.

Where did you buy this kit?  Depending on who sold it to you, they might have datasheets for all the sensors.  If not try doing a Google search for the part's datasheets.

seadanzig

The chinese data sheet requires capacitors in the circuit have you wired it up as the sheet

Ampix0

I have a book coming about basics of electronics and arduino.
Maybe I'll slow down a bit until my book arrives.

For those interested Here's the book.

terryking228

Hi, You are using an IR Receiver that gets complex data, not just a single value.

See: http://arduino-info.wikispaces.com/IR-RemoteControl  for some information.

Maybe look at more INFO on the ArduinoInfo WIKI here - http://arduinoinfo.info
Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

seadanzig

Ampix

Google ladyada ir tutorial that should help you

Go Up