0

我只想要函数的距离值,如果我打印working_odo,它会在while循环中驱动我。我只想要距离

def working_odo(): 
    last_state=IO.input(15)
    state_count=0
    while 1:
        current_state=IO.input(15)
        if(current_state!=last_state):
            state_count+=1
            #print(state_count)
            last_state=current_state
            distance = 0.001*state_count

这是编码器的覆盆子 gpio 代码

4

1 回答 1

0

我不确定你是否正确,也许:

def working_odo(): 
   # YOUR implementation here
   while ... :
       if (current_state != ... :
           return distance # ?
于 2020-09-19T11:18:07.880 回答