can I do serial output while in an interrupt-called function?

I have a motorshield stacked on an ethernet shield stacked on a duemilanove arduino. I have a switch connected to digital pin 13, which is set to high, with the other end of the switch connected to digital pin 2, with a resistor between pin 2 and ground. I’m trying to use an interrupt to see when pin 2 goes high when the switch closes. This seems to work ok, but I also wanted to write from the interrupt-called function that the switch has closed. In the attached code, a motor (1) is started, then there is a loop to wait for the interrupt. The motor starts, and stops when the switch is closed, but the serial println doesn’t show up on the serial monitor. Any ideas as to why this is the case? Eventually I also wanted the stop function to post something to a client. If I can’t write from within the stop function I probably could monitor the status in the while loop instead… Should I be able to do this serial output? Maybe there are some pin conflicts that prevent the serial write when pin 2 is high?

#include <AFMotor.h>
#include <SPI.h>
AF_DCMotor motor(1, MOTOR12_64KHZ); // create motor #2, 64KHz pwm
void setup() {
  motor.setSpeed(200);     // set the speed to 200/255
  // use interrupt 0 (pin 2 on duelimove)
  attachInterrupt(0, stop, RISING);
  Serial.println("starting motor");;
  pinMode(13, OUTPUT);
  //pinMode(2, INPUT);

void loop() {


void stop() {
  Serial.println("interrupt detected stopping motor");;

I've got to ask why you feel you need an interrupt.

That’s a good question. I originally wanted to just do a loop after starting the motor until the switch closed, but the command wasn’t executing when I put any kind of loop after it. When I took the loop out, it did execute. So I tried the interrupt approach. It actually does work to shut off the motor when the switch closes, but I don’t get any output while in the interrupt function. I reread the Arduino reference and it says serial data may be lost in the interrupt routine. Thanks for bringing me back to what I originally was trying to do. Here’s the bit of code that turns the motor on and then is supposed to wait for the switch to close. When the “while {” and closing “}” are commented out, the motor will turn on. If I put the while loop back in, the motor doesn’t turn on.

    Serial.println("opening door");
    client.println("<p>Internet Door Controller
Waiting for door to open&nbsp;</p>");;

    //while (digitalRead(2) == LOW ){
            Serial.print("serial pin 2 = ");
            Serial.print("  serial pin 14 = ");