Arduino is an open-source electronics platform used to build:
It consists of:
π https://www.arduino.cc/en/software
Windows / Mac / Linux supported
Your computer will install drivers automatically.
Tools β Board β Arduino Uno
Tools β Port β COMX (Arduino Uno)
Basic program structure:
void setup() {
// runs once
}
void loop() {
// runs forever
}
setup() initializes pins, communicationβ¦loop() is the program that runs repeatedly (like a continuous cycle)
Code: Blink LED
void setup() {
pinMode(13, OUTPUT); // Use pin 13
}
void loop() {
digitalWrite(13, HIGH); // LED ON
delay(1000); // wait 1 sec
digitalWrite(13, LOW); // LED OFF
delay(1000);
}
Upload β The LED blinks every second.
Congratulations! You executed your first microcontroller program!

Code
int button = 2;
int led = 13;
void setup() {
pinMode(button, INPUT);
pinMode(led, OUTPUT);
}
void loop() {
int state = digitalRead(button);
if (state == HIGH) {
digitalWrite(led, HIGH);
} else {
digitalWrite(led, LOW);
}
}
Now the LED turns ON when you press the button.
This teaches you analog signals and analogRead().

Code
int pot = A0;
int value;
void setup() {
Serial.begin(9600);
}
void loop() {
value = analogRead(pot); // read 0β1023
Serial.println(value);
delay(200);
}
Open Serial Monitor β you will see the values change.
Using analogWrite() on a PWM pin (marked with ~).
int led = 9;
int brightness = 0;
void setup() {
pinMode(led, OUTPUT);
}
void loop() {
for (brightness = 0; brightness <= 255; brightness++) {
analogWrite(led, brightness);
delay(10);
}
for (brightness = 255; brightness >= 0; brightness--) {
analogWrite(led, brightness);
delay(10);
}
}
LED will fade in and out smoothly.

Code
#define trig 9
#define echo 10
void setup() {
Serial.begin(9600);
pinMode(trig, OUTPUT);
pinMode(echo, INPUT);
}
void loop() {
digitalWrite(trig, LOW);
delayMicroseconds(2);
digitalWrite(trig, HIGH);
delayMicroseconds(10);
digitalWrite(trig, LOW);
long duration = pulseIn(echo, HIGH);
long distance = duration * 0.034 / 2;
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
delay(300);
}
Now you have a basic radar distance measurement system.
Used in:

Code
#include <Servo.h>
Servo motor;
void setup() {
motor.attach(9);
}
void loop() {
motor.write(0);
delay(1000);
motor.write(90);
delay(1000);
motor.write(180);
delay(1000);
}

Code
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();
Serial.print("Temp: "); Serial.print(t); Serial.println("Β°C");
Serial.print("Hum: "); Serial.print(h); Serial.println("%");
delay(1000);
}
You now have a mini-weather station.
By completing these lessons, youβve learned:
| Skill | Explanation |
|---|---|
| Digital I/O | Using pinMode, digitalRead, digitalWrite |
| Analog Input | Reading sensors with analogRead |
| PWM Output | Controlling brightness and speed |
| Serial Monitor | Displaying sensor data |
| Using Libraries | (Servo, DHT, etc.) |
| Basic Circuits | Breadboarding + resistors |
You now have enough knowledge to build real-world Arduino projects.
