[Resolved] Erratic operation when motor is supposed to be "asleep"

All the variables you use to communicate with an interrupt routine must be declared "volatile".

Also you need to turn off interrupts whenever you change these variables from loop(), since
they are int, they are 2 bytes, and the ATmega is an 8 bit machine, so when you change
a 16 bit int you are doing two memory accesses, and the interrupt routine could run inbetween
the write to each byte.

volatile int RED = 0 ;
...

...
  noInterrupts () ;
  RED = (int) motor ;  // ensure atomic update of RED.
  interrupts () ;
...

These are basic rules you always have to follow for using interrupts.