Using the same pin for input and output?

Is it possible to use pins as both input and output in different steps of a programm?

Let say i want to power a small motor at the start of a program and later i want to meassure if it is moved by outside forces, where do i change the pins from output to input? Is it possible to do so in "loop" ?

I just recently started to learn Arduino, I hope Iam not asking stupid questions.

You can use the same pin for input and output at various stages of the program but this is almost never done for the reason that you have to have the correct sort of hardware.

Things like the I2C data pin does this. You normally do this when talking to other chips not you hardware.

What you describe however does not sound feasible. Try drawing a schematic of your proposal.