IR Detector - not working with Mega2560

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
iisfaq
 
Posts: 1
Joined: Sat Jun 16, 2012 3:16 pm

IR Detector - not working with Mega2560

Post by iisfaq »

Hi all

Just getting started and I am having problems with getting the IR Detector project from http://www.ladyada.net/learn/sensors/ir.html working.

I have a Deumilanoye and it works in that but i nthe Mega 2560 it does not.

I tested the pin using a simple LED and can get it to flash so I assume that the direct pin connection may be a problem.
// We need to use the 'raw' pin reading methods
// because timing is very important here and the digitalRead()
// procedure is slower!
//uint8_t IRpin = 2;
// Digital pin #2 is the same as Pin D2 see
// http://arduino.cc/en/Hacking/PinMapping168 for the 'raw' pin mapping
#define IRpin_PIN PIND
#define IRpin 2
I have looked at the pin image for the 2560 but not sure what I am looking at - it looks like it could be pin 4 instead of 2? but I do not know :-(

Image

Any help appreciated

cheers

chris

Keith777
 
Posts: 1
Joined: Sat Jul 21, 2012 10:44 pm

Re: IR Detector - not working with Mega2560

Post by Keith777 »

I had the same problem and trying to find the correct pin on the mapping diagram didn't help anything.
I found the pin that works by just trying others. PIN 19 (rx1) is the one and I don't even see it on the mapping diagram.

-Keith

TaylorHolmes
 
Posts: 6
Joined: Sun Apr 10, 2011 11:20 pm

Re: IR Detector - not working with Mega2560

Post by TaylorHolmes »

Has anyone figured out a working solution to this that they've tried? I'm having the same problem as iisfaq
(OP). I'm using the IR sensor - TSOP38238 (https://www.adafruit.com/products/157) with an Arduino Mega 2560 R3. I've tried everything in this thread, including the code that the last poster (aldan4uk) suggested, with no luck so far. At this point I'm just using trial and error, but it might take a while.

I was hoping that since this IR sensor is sold by adafruit, perhaps a bit of support is what we need.

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: IR Detector - not working with Mega2560

Post by adafruit »

use pin PINE and 4 not PINE and 2 - not sure why he said E2

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: IR Detector - not working with Mega2560

Post by adafruit_support_rick »

It works for me.
I'm using the sketch downloaded from github.
I made the following mod for use with the Mega 2560

Code: Select all

//#define IRpin_PIN      PIND
//#define IRpin          2
// for MEGA use these!
#define IRpin_PIN PINE
#define IRpin 4
I have the following connections:

Code: Select all

Sensor  Mega
------  ----
  1     digital 2
  2     GND
  3     5V
Make sure you have correctly identified pin 1 on the sensor, Looking at the domed side, pin 1 is the leftmost pin.

Make sure you're connecting to digital 2 on the mega (not digital 4).

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”