๐ Software Errors & Debugging Techniques
๐ฏ Lesson Objective
In this lesson, students will learn:
- How to identify and fix software errors
- Types of programming errors (syntax, logical, runtime)
- How to use Serial Monitor for debugging
- How to debug Blynk communication issues
By the end of this lesson, students will be able to analyze, debug, and fix code-related problems efficiently.
๐ง Why Software Debugging is Important
Even if hardware is perfect:
- A small coding mistake can stop the system
- Wrong logic can cause incorrect movement
๐ Debugging is a core skill of every programmer
๐ 1. Types of Software Errors
๐น 1. Syntax Errors
๐ What it is:
Mistakes in code writing (grammar of programming)
Examples:
- Missing
; - Wrong brackets
{} - Misspelled keywords
Result:
- Code will NOT compile
Solution:
- Read error message carefully
- Fix syntax in code
๐น 2. Logical Errors
๐ What it is:
Code runs, but output is wrong
Example:
๐ Should be:
Result:
- Robot behaves incorrectly
Solution:
- Check logic carefully
- Use print statements
๐น 3. Runtime Errors
๐ What it is:
Errors during execution
Examples:
- WiFi not connected
- Blynk not responding
Result:
- Program runs but does nothing
๐ง 2. Debugging Using Serial Monitor
๐น Why Serial Monitor?
It helps you:
- See what ESP32 is doing
- Print values and messages
- Track errors in real-time
๐น Basic Debug Example
๐ This helps you know:
- Is function being called or not
๐น Debugging Blynk Input
int value = param.asInt();
Serial.print(“V0 Value: “);
Serial.println(value);
if(value == 1) {
forward();
}
}
๐ Output:
- Shows button value (0 or 1)
๐ 3. Debugging Strategy (Step-by-Step)
โ Step 1 โ Check Compilation
- Fix all red errors
โ Step 2 โ Add Serial Prints
- Print values at important points
โ Step 3 โ Verify Logic
- Check conditions (
if,else)
โ Step 4 โ Test Functions Individually
- Call
forward()manually
โ Step 5 โ Check Input Values
- Verify Blynk data
โ ๏ธ 4. Common Software Errors
| Problem | Cause | Solution |
|---|---|---|
| Robot not responding | Blynk not connected | Check Auth Token |
| Wrong movement | Logic error | Fix conditions |
| No output in Serial | Wrong baud rate | Set 9600 |
| Code not uploading | Port issue | Select correct port |
๐ 5. Debugging Blynk Connection
Symptoms:
- Device shows OFFLINE
- Buttons not working
Solution:
- Check WiFi
- Check Auth Token
- Re-upload code
๐ง 6. Pro Debugging Tips
- Always print values
- Debug step-by-step
- Donโt change everything at once
- Test small parts
๐งช 7. Practical Debug Exercise
Give students this:
๐ โRobot is not moving when button is pressedโ
Students must:
- Print button value
- Check function call
- Identify issue
๐ง Important Mindset
โ โCode is not workingโ
โ
โWhich part of code is not working?โ
๐ Lesson Summary
In this lesson, students learned how to identify and fix software errors using proper debugging techniques. They also learned how to use Serial Monitor to track program execution and solve real-world problems.
๐ Practice Task
- Add Serial print in all movement functions
- Print WiFi status
- Print Blynk values