Raspberry Pi segmentation fault - Python -
i have program on raspberry pi written on python use control 2 motors. here of code :
def fullleft() : speed1 = motor1speed speed2 = motor2speed setmotor1speed(100) setmotor2speed(-100) while io.input(forward1control) , io.input(backward2control) : print( "%d : %d" %(motor1speed,motor2speed)) stop() setmotor1speed(speed1) setmotor2speed(speed2) print("left done") def fullright() : speed1 = motor1speed speed2 = motor2speed setmotor1speed(-100) setmotor2speed(100) while io.input(forward2control) , io.input(backward1control) : print( "%d : %d" %(motor1speed,motor2speed)) stop() setmotor1speed(speed1) setmotor2speed(speed2) print("right done") def stop () : io.output(forward1out,false) motor1forward.stop() io.output(backward1out, false) motor1backward.stop() io.output(forward2out, false) motor2forward.stop() io.output(backward2out, false) motor2backward.stop() global motor1speed motor1speed = 0 global motor2speed motor2speed = 0
everything worked before introduce stop()
function on fullright()
method. problem fullleft()
works after 2nd while loop on fullright()
function, have error segmentation fault
, program crashes. don't know , why happening. can me figure out problem is...
Comments
Post a Comment