moved gpio control to another thread