give your motor voltage and current rating then only we can say that motor will damage your arduino ar not. As far as i know there are some motors which are rated as 5v, 0.02 -0.03A.
and for the code it is better you connect led to digital pin and use the following
if digitalpin == HIGH
motor stop
if digitalpin == LOW
motor on