๐Ÿ“˜ 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:

ย 
if(value == 0) forward();
ย 

๐Ÿ‘‰ Should be:

ย 
if(value == 1) forward();
ย 

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

ย 
Serial.println(“Forward button pressed”);
ย 

๐Ÿ‘‰ This helps you know:

  • Is function being called or not

๐Ÿ”น Debugging Blynk Input

ย 
BLYNK_WRITE(V0) {
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