When I run the program I wrote for mission 4 and then press the ‘Stop GoPiGo’ button, the sound output in both the terminal window and the scratch cat keep getting generated. Additionally, when the motor is running the motor will just keep running. The only way I get it to stop is to restart scratch. Any ideas on how to fix it?
Are you referring to the red “Stop GoPiGo” button in the Scratch for Robots window? This is only meant to stop the motors if by mistake you end up with a runaway robot. It is not meant to stop your Scratch program. For that, you should click on the red stop sign, in the top right corner of the Scratch application
Does that work better? Otherwise, can you take a picture of your code, and post it here. It will help in seeing what’s going on.
That’s right, the button in the Scratch for Robots window. The red stop sign doesn’t do anything for me. I’m attaching a photo of my code.
Trying again on the attachment
THank you for the screenshot of your code. It’s easier to debug that way.
You need some delays in that code. It runs too fast for GoPiGo, and the robot is getting flooded by the broadcast commands. And it will go through every single broadcast before it will stop. You can try with a delay of 0.5 seconds. It takes a bit of experimenting. It depends on which Raspberry Pi you have, which SD card. Sometimes it’s 0.2 seconds, sometimes it’s more. It also depends on your code.
Let me know if that helps.
Thanks Cleo, adding delays did the trick.
Super! And thanks for getting back to me on this.
Onwards to next mission!