Motor and sensor

Swaggydogy:
But it make error because i think the:

for (int i = 0; i <= 50; i++)

doesn't work with the 'if'

Of course it won't. Why would you expect the code for a FOR loop to work with an IF statement.

Please put this project to one side for the moment and, as I suggested in Reply #22, take some time out to learn the basics of programming.

...R