Pages: [1]   Go Down
Author Topic: Interrupt Issues, Interrupt 5 not working  (Read 221 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello. I am new to Arduino, but very excited to be using it. It has been very simple in all other aspects until I tried to use the interrupts. I have a PIR motion sensor (http://www.robotshop.com/productinfo.aspx?pc=RB-See-194&lang=en-US) attached to the arduino mega 2560 ADK R3 board (http://arduino.cc/en/uploads/Main/ArduinoADKFront.jpg). I have connected the motion sense pin of the sensor to pin 18 (interrupt 5) of the board. Have confirmed the pin out and I have confirmed that the pin does in fact go high for about 3 seconds when motion is detected. I have confirmed this with a volt meter and I have connected the pin to the analog A1 input to read the voltage. So it is fully functioning. However when I connect it to pin 18 and set up the pin for the interrupt I cannot get it to detect the rising edge of the motion sense pin and call the ISR. I have tried to move the pin to interrupt 0 and interrupt 1. I cannot use these pins in my design because I intend to use those ports for communication with other devices. The following is my code that I am trying to use.

Can anyone give me an idea of what I am doing wrong?

/**********
Motion Sensor Code
***********/

int motionPin = 18;
volatile int motionSensorState = LOW;

void setup(){
// Open serial 0 communications and wait for port to open:
 //Serial port 0 will be used to send debugger messages to the PC
 //that is connected via the USB port.
 Serial.begin(57600);

pinMode(motionPin, INPUT);
attachInterrupt(5, pin5isr, RISING);
Serial.println("Motion Sensor Pin configured");
}

void loop() {
if(motionSensorState){
Serial.println("Motion Detected");
motionSensorState = LOW;
}
}

void pin5isr()
{
  motionSensorState = HIGH;
}
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 538
Posts: 27115
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

And please don't post the same thing in multiple places - i.e. crosspost - we'll see it & move it if needed.
Thanks
Moderator
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26336
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Useful reading here and here

Please don't cross-post. Your duplicate post has been deleted.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Pages: [1]   Go Up
Jump to: