Translation of arduino code to pure c