Also we need to distinguish responding to the environment and even making decisions from experiencing pain.
I can make a robot from Lego that follows a line pretty well but I think we're all pretty comfortable with the idea it is vanishingly unlikely to feel pain (although there are people who feel punishment machine learning schemes are unethical lol).