added interrupts

improved encoder rotation recognition; some preparations to use timer
and interrupts.
delay_ms replaced with timer
fixed missed b11 write