def control(): # Main function of program from which other functions are called sun_result = [0,0,0] # Initializing sun_result num = 1 print "Enable sun sensor №", num sun_sensor_turn_on(num) sleep(1) print "Get RAW data from sun sensor" for i in range(10): sun_result = sun_sensor_request_raw(num) if not sun_result[0]: # if sensor returns error message, print "state:", sun_result[0], "raw =", sun_result[1], \ sun_result[2] elif sun_result[0] == 1: print "Fail because of access error, check the connection" elif sun_result[0] == 2: print "Fail because of interface error, check your code" sleep(1) print "Disable sun sensor №", num sun_sensor_turn_off(num)