📘 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