12. Debugging
12.1. Data Wires
A Data Wire allows you to take an output from one programming block and input it into another.
12.2. Debugging techniques
– Button press
– Light
– Sound
– Display
Debugging is a useful strategy to figure out where in your program something is going wrong or what went wrong
Once your code starts to become long or complicated (e.g. using sensors), it can become hard to figure out where in the program you are
The following slides show you some ways of knowing where you are in your program or knowing what values your sensors see
Wait For Button Press
To place a Wait for Button Press block in your program, place a wait block into your program
Go under brick buttons > compare > brick buttons, then choose which button needs to be pressed to continue the program
Place these wait for button presses every block or two close to where the robot is not working correctly
This can help you pinpoint which block is causing the robot to fail
The robot will stop and “wait for you to press the button”
Sound Alerts: Sound Block
You can insert different sounds at intervals (about every 5 blocks or so), and then run the program again while listening for beeps.
Once you pick Play Tone, select Play Type and pick “play once”
These sounds can help you narrow down where in the program something is going wrong.
Print to Screen: Display Block
Showing which block is playing on your robot
Helps identify what block the robot is stuck on
Seeing the sensor readings – to see what the robot sees!