Arduino Course

Learn Arduino step by step with circuits, code, practice tasks, and troubleshooting.

Lesson 1: What Is Arduino?

Arduino is a small programmable board used to read sensors and control outputs like LEDs, buzzers, motors, relays, and displays.

You Need

Rule: always connect GND correctly. Most beginner problems happen because the ground connection is missing or loose.

Lesson 2: Arduino IDE Setup

  1. Install Arduino IDE.
  2. Connect the board with USB.
  3. Select board: Arduino Uno or the board you are using.
  4. Select the correct port.
  5. Upload the Blink example.

Common Upload Fixes

Lesson 3: Blink LED

Connect LED positive leg to pin 13 through a 220 ohm resistor. Connect LED negative leg to GND.

void setup() {
 pinMode(13, OUTPUT);
}

void loop() {
 digitalWrite(13, HIGH);
 delay(1000);
 digitalWrite(13, LOW);
 delay(1000);
}

Practice

Lesson 4: Push Button Input

A button is an input. Use INPUT_PULLUP to avoid unstable readings without an extra resistor.

const int buttonPin = 2;
const int ledPin = 13;

void setup() {
 pinMode(buttonPin, INPUT_PULLUP);
 pinMode(ledPin, OUTPUT);
}

void loop() {
 int pressed = digitalRead(buttonPin) == LOW;
 digitalWrite(ledPin, pressed);
}
With INPUT_PULLUP, the button reads LOW when pressed and HIGH when released.

Lesson 5: Analog Sensor Reading

Analog pins read values from 0 to 1023. A potentiometer or soil moisture sensor can be tested here.

void setup() {
 Serial.begin(9600);
}

void loop() {
 int value = analogRead(A0);
 Serial.println(value);
 delay(300);
}

Practice

Lesson 6: Servo Motor

A servo moves to an angle. Use external 5V power for larger servos and connect Arduino GND to servo power GND.

#include <Servo.h>

Servo myServo;

void setup() {
 myServo.attach(9);
}

void loop() {
 myServo.write(0);
 delay(700);
 myServo.write(90);
 delay(700);
 myServo.write(180);
 delay(700);
}

Lesson 7: Ultrasonic Distance Sensor

HC-SR04 uses trigger and echo pins to measure distance.

const int trigPin = 9;
const int echoPin = 10;

void setup() {
 Serial.begin(9600);
 pinMode(trigPin, OUTPUT);
 pinMode(echoPin, INPUT);
}

void loop() {
 digitalWrite(trigPin, LOW);
 delayMicroseconds(2);
 digitalWrite(trigPin, HIGH);
 delayMicroseconds(10);
 digitalWrite(trigPin, LOW);

 long duration = pulseIn(echoPin, HIGH);
 int distance = duration * 0.034 / 2;
 Serial.println(distance);
 delay(300);
}

Final Project: Mini Obstacle Alert

Build a device that beeps when an object is closer than 15 cm.