I just want the distance value from the function

24 views Asked by At

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

1

There are 1 answers

0
mrvol On

I am not sure that got you correctly, maybe:

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