Go Down

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

#### Ampix0

##### Sep 26, 2012, 06:36 pm
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.

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

#1
##### Sep 26, 2012, 06:43 pm
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

#2
##### Sep 26, 2012, 06:51 pm

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

#3
##### Sep 26, 2012, 06:58 pm
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

#4
##### Sep 26, 2012, 07:05 pm

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

#5
##### Sep 26, 2012, 07:11 pm

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

#6
##### Sep 26, 2012, 07:32 pm
The chinese data sheet requires capacitors in the circuit have you wired it up as the sheet

#### Ampix0

#7
##### Sep 26, 2012, 07:40 pm
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

#8
##### Sep 26, 2012, 08:15 pm
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

#9
##### Sep 26, 2012, 09:35 pm
Ampix

Google ladyada ir tutorial that should help you

Go Up

Please enter a valid email to subscribe

### Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy