def control(): # Main program function in which other functions are called hyro_result = [0,0,0,0] # Initializing hyro_result num = 1 # Number of angular velocity sensor print "Enable angular velocity sensor №", num hyro_turn_on(num) # Turning angular velocity sensor on sleep(1) # Waiting for 1 second for sensor to turn on print "Get RAW data from angular velocity sensor" for i in range(10): # Reading the indication for 10 times hyro_result = hyro_request_raw(num) # recording function answer # hyro_request_raw to variable hyro_result if not hyro_result[0]: # if sensor does not return error message, print "state:", hyro_result[0], "x_raw =", hyro_result[1], \ "y_raw =", hyro_result[2], "z_raw =", hyro_result[3] # Data output elif hyro_result[0] == 1: # if sensor returns error message 1 print "Fail because of access error, check the connection" elif hyro_result[0] == 2: # if sensor returns error message 2 print "Fail because of interface error, check your code" sleep(1) # Indications are read one time per second print "Disable angular velocity sensor №", num hyro_turn_off(num) # Turning angular velocity sensor off