0

I just want the distance value from the function, if i print the working_odo it drives me in the while loop. I just want distance

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

This is a raspberry gpio code for encoder

Stanislav Ivanov
  • 1,854
  • 1
  • 16
  • 22

1 Answers1

0

I am not sure that got you correctly, maybe:

def working_odo(): 
   # YOUR implementation here
   while ... :
       if (current_state != ... :
           return distance # ?
mrvol
  • 2,575
  • 18
  • 21