【问题标题】:I just want the distance value from the function我只想要函数的距离值
【发布时间】:2021-01-06 02:53:51
【问题描述】:

我只想要函数的距离值,如果我打印 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代码

【问题讨论】:

    标签: python-3.x raspberry-pi4 pigpio


    【解决方案1】:

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

    def working_odo(): 
       # YOUR implementation here
       while ... :
           if (current_state != ... :
               return distance # ?
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-21
      • 1970-01-01
      • 2014-09-30
      • 1970-01-01
      • 2023-01-20
      • 2018-10-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多