Converting a piece of PIC code to Arduino