Thank you very much Melanie, i will study it carefully and try it. Most of my PORTB pins are busy especially PORTB.0 as external interrupt input. Hope i should be able to use other PORTB pins.

Can i use PORTC pins? I don't think they have weak pull-up resistors though. How can i connect the resistors exteranlly?

I will try it and let you know.

Kind regards,
Tom.