Start of the port of the arduino code (for controlling motors etc) into c