Fixed some port gliches

Ensure the code is fully suitable on Arduino, in addition to Raspberry