beginner, need help with dc motor control

You need some sort of driver to convert the small ammount of current from the pin into enough to drive the motor.
As for software it is just like you do the same thing with a LED look at the examples in the arduino software about detecting a change in state of the input, not just reading its value.