Arduino malfunctions occasionally, could this be a programming error?