Back to Learn
IoT • Beginner

Arduino & Sensors 101

Get started with Arduino boards, sensors, and actuators. Build your first IoT prototype step-by-step.

Arduino & Sensors Cover

Introduction to Arduino

Arduino is an open-source electronics platform based on easy-to-use hardware and software. Arduino boards can read inputs — a sensor detecting light, a finger pressing a button — and turn them into outputs — activating a motor, turning on an LED, or publishing data online.

Here's the classic "Blink" sketch — the Hello World of Arduino:

// Blink — turns an LED on and off repeatedly

void setup() {
    // Initialize digital pin LED_BUILTIN as output
    pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
    digitalWrite(LED_BUILTIN, HIGH);  // LED on
    delay(1000);                      // Wait 1 second
    digitalWrite(LED_BUILTIN, LOW);   // LED off
    delay(1000);                      // Wait 1 second
}

Working with Sensors

Sensors are the eyes and ears of your IoT project. The DHT11 temperature and humidity sensor is one of the most popular for beginners. It communicates digitally and works with a simple library. Other common sensors include ultrasonic (HC-SR04), PIR motion, and light-dependent resistors (LDR).

Read temperature and humidity from a DHT11 sensor:

#include <DHT.h>

#define DHTPIN 2        // Data pin
#define DHTTYPE DHT11   // Sensor type

DHT dht(DHTPIN, DHTTYPE);

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

void loop() {
    float humidity = dht.readHumidity();
    float tempC    = dht.readTemperature();

    Serial.print("Temp: ");
    Serial.print(tempC);
    Serial.print("°C  |  Humidity: ");
    Serial.print(humidity);
    Serial.println("%");

    delay(2000);  // Read every 2 seconds
}

Controlling Actuators

Actuators are the muscles of your project — they make things happen. Servo motors, relays, buzzers, and LCD displays are common actuators. You can combine sensor inputs with actuator outputs to create smart, automated systems.

Control a servo motor based on sensor input:

#include <Servo.h>

Servo myServo;

void setup() {
    myServo.attach(9);    // Servo on pin 9
    Serial.begin(9600);
}

void loop() {
    int sensorValue = analogRead(A0);  // Read sensor

    // Map sensor range (0-1023) to angle (0-180)
    int angle = map(sensorValue, 0, 1023, 0, 180);

    myServo.write(angle);
    Serial.print("Angle: ");
    Serial.println(angle);

    delay(100);
}

Key Takeaway

Arduino makes hardware programming accessible to everyone. By combining sensors (input) with actuators (output), you can build anything from smart home systems to environmental monitors — the foundation of every IoT solution.