code for line following robot not working perfectly
This test:

if (tmp = 1)


is always true. You are assigning 1 to tmp and that value (1), when
interpreted in a boolean context (i.e. as a truth value), is true.

You probably mean

if (tmp == 1)


and similarly for the next test.