Converting a code from AVR to arduino