Embedded C++ Developer Course

What is C and C++?

C is a procedural programming language developed in the 1970s for low-level system programming. It is widely used for developing firmware and portable applications. C++ is an extension of C that includes object-oriented features like classes and objects, allowing structured and reusable code — ideal for embedded systems.

What is a Header File in Arduino?

Header files (.h) in Arduino contain predefined functions and macros. They help organize code and reuse functionality. For example: #include <Wire.h> allows I2C communication.

10 Common Arduino Header Files:

What is main() and Return Type?

The main() function is the entry point of any standard C/C++ program. It tells the processor where to start execution. In Arduino, however, we use setup() and loop() functions instead. Internally, Arduino wraps your code in a main() function.

Basic Blink LED Code

void setup() {
  pinMode(13, OUTPUT); // Set pin 13 as output
}

void loop() {
  digitalWrite(13, HIGH); // Turn ON LED
  delay(1000);            // Wait 1 second
  digitalWrite(13, LOW);  // Turn OFF LED
  delay(1000);            // Wait 1 second
}
    

This code blinks the onboard LED connected to pin 13 every second.

Using the Serial Monitor in Arduino

void setup() {
  Serial.begin(9600); // Start serial communication at 9600 baud
}

void loop() {
  Serial.println("Hello from miniBotix!"); // Print message
  delay(1000); // Wait 1 second
}
    

This program sends text to the Serial Monitor every second.
Open Serial Monitor in Arduino IDE (Ctrl+Shift+M or Tools > Serial Monitor) to view the messages.

Temperature Sensor with Buzzer (If Temp > 35°C)

#define sensor A0
#define buzzer 9

void setup() {
  pinMode(buzzer, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  int temp = analogRead(sensor); // Read analog value
  float celsius = (temp * 5.0 * 100) / 1024;
  Serial.println(celsius); // Display temperature

  if (celsius > 35) {
    digitalWrite(buzzer, HIGH);  // Buzzer ON
  } else {
    digitalWrite(buzzer, LOW);   // Buzzer OFF
  }

  delay(1000);
}
    

This code reads temperature from an analog sensor and activates a buzzer when the temperature crosses 35°C. It also prints temperature to the Serial Monitor.