Updated Arduino script with some functionality from original project