Copmleted code for Arduino