Pages: [1]   Go Down
Author Topic: First time playing with an IR sensor.  (Read 2089 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 18
Teknue.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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. smiley-razz

Code:
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);
}
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 18
Teknue.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 18
Teknue.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

USA
Offline Offline
God Member
*****
Karma: 14
Posts: 644
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 18
Teknue.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Topsham, Vermont USA
Offline Offline
Edison Member
*
Karma: 23
Posts: 1753
... in The Woods In Vermont
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ampix

Google ladyada ir tutorial that should help you
Logged

Pages: [1]   Go Up
Jump to: