def followVoice(self): adc = MCP3008() while True: front = adc.read(0) right = adc.read(1) left = adc.read(2) # tiny values are invalid => map them to 1023 if front < 10: front = 1023; # motors make noise of about 150, if motor is running if right < 50: right = 1023; if left < 50: left = 1023; if front < 1000 and right > 1000 and left > 1000: self.motor.forwardRight() elif front > 1000 and right < 1000 and left > 1000: self.motor.forwardLeft() elif front > 1000 and right > 1000 and left < 1000: self.motor.forwardRight() elif front < 1000 and right < 1000 and left > 1000: # front / right self.motor.forwardLeft() time.sleep(self.motor.SEC_PER_TURN / 360.0 * 45) elif front < 1000 and right > 1000 and left < 1000: # front / left self.motor.forwardRight() time.sleep(self.motor.SEC_PER_TURN / 360.0 * 45) else: self.motor.stop() time.sleep(0.1)