DC Motor + PIR Sensor

In the code you have Serial commands intended to print "Motion detected!" or "Motion stopped!". Do they?

If not, it might also be worth temporarily adding a print immediately after the sensor read to see if anything is getting to the Arduino. E.g.

  val = digitalRead(sensor);   // read sensor value
  Serial.print(val);

What do you see? That should tell you if the PIR information is getting into the Arduino.

As for ground, the question meant "Are all ground pins, on the PIR, the breadboard/motor driver and the Arduino itself connected together"? Missing a ground link is a common problem when things don't work and I can't tell from your photo if there is any ground connection between the Arduino and the breadboard.

Motor pins. Nothing is ever written to DIRB. And in your "else" you write only to DIRA. BTW I'm guessing that your motor driver is an L293. Is that correct?

Steve