added code from arduino sketch project