Most likely cause I can see: you have a rogue space in line 49: `pi. wave_tx_stop()` should be `pi.wave_tx_stop()`