←Back to Subject
Notes
Notes
Study material and explanations
Diagrams
Diagrams
Visualize concepts easily
Mnemonics
Mnemonics
Tricks to remember faster
One Night Prep
One Night Prep
Short and focused revision
Revision
Revision
Quick summary and key points
Important Questions
Important Questions
Practice most relevant questions
Notes

Arduino Uno: Architecture, GPIO Pinout & Programming

Study material and explanations for Unit 5

Arduino Uno: Architecture, GPIO Pinout & Programming

1. What is Arduino Uno? (In Simple Words)

Arduino Uno is an open-source electronics development board that is world-famous among college students, hobbyists, and engineers. It is very popular because you can simply plug it into your laptop with a USB cable and start programming right away!

At the heart of the Arduino Uno is a small black computer chip called the ATmega328P microcontroller. It reads inputs from sensors (like temperature, light, motion) and turns ON physical outputs (like an LED light, motor, buzzer, or relay switch).

Arduino Uno R3 Key Hardware Specifications
Microcontroller Chip
ATmega328P (8-bit AVR RISC architecture)
Clock Speed
16 MHz crystal oscillator (runs 16 million instructions/sec)
Operating Voltage
5V DC (Can take 7V to 12V through the black DC power jack)
Memory Breakdown
32 KB Flash (stores your code), 2 KB SRAM (variables), 1 KB EEPROM (permanent storage)

2. GPIO Pinout and Hardware Layout

The Arduino Uno board has 28 external header pins where you can plug jumper wires:

                     ┌──────────────────┐
         [USB Port] ──┤                  ├── [DC Power Jack: 7-12V]
                      │   ATmega16U2     │
        [Reset Button]│   (USB to Serial)│
                      │                  │
         Digital Pins │                  │ Analog Input Pins
         [0 to 7]     │   ATmega328P     │ [A0 to A5]
         [8 to 13]    │   (Main MCU)     │ Power Pins:
         (PWM: ~3,5,  │                  │ [5V, 3.3V, GND, Vin]
          6,9,10,11)  │                  │
                      └──────────────────┘

Detailed Breakdown of Arduino Pins for Exams:

Pin Group Pin Numbers What They Do & How They Work
Digital I/O Pins Pins 0 to 13 (14 pins) Can be set as INPUT or OUTPUT. Works with digital signals: HIGH (5V) or LOW (0V).
PWM Output Pins Pins 3, 5, 6, 9, 10, 11 (marked with ~) Pulse Width Modulation. Simulates analog voltages (0V to 5V) to dim an LED or change motor speed (values 0 to 255).
Analog Input Pins Pins A0 to A5 (6 pins) Built-in 10-bit ADC. Converts analog sensor voltages (0V to 5V) into numbers from 0 to 1023.
Hardware Serial (UART) Pin 0 (RX) & Pin 1 (TX) Used for serial communication with computers (Serial Monitor) and Bluetooth/GPS modules.
SPI Interface Pins 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK) High-speed hardware SPI communication for SD cards and RFID readers.
I2C Interface Pin A4 (SDA) & Pin A5 (SCL) Two-wire serial interface for OLED displays and digital sensors.
Power Pins 5V, 3.3V, GND, Vin Supplies 5V or 3.3V power to external sensors; GND connects ground wires.

3. Arduino Software & Programming Model

Arduino programs are written in C/C++ using the free Arduino IDE software.

Every Arduino program (called a sketch) has two mandatory functions:

void setup() {
  // This code runs only ONCE when Arduino powers ON or resets.
  // We use it to set pin modes and start serial communication.
}

void loop() {
  // This code runs FOREVER in a continuous loop.
  // We use it to read sensors and turn on lights/motors.
}

Common Built-In Arduino Functions:

  • pinMode(pin, mode): Configures a pin as INPUT or OUTPUT (e.g. pinMode(13, OUTPUT);).
  • digitalWrite(pin, value): Sets a digital pin to HIGH (5V) or LOW (0V).
  • digitalRead(pin): Reads whether a pin is receiving HIGH or LOW.
  • analogRead(pin): Reads an analog pin (A0-A5) and gives a number from 0 to 1023.
  • analogWrite(pin, value): Sends a PWM value (0 to 255) to control LED brightness or motor speed.
  • delay(ms): Pauses program execution in milliseconds (e.g. delay(1000) pauses for 1 second).
  • Serial.begin(baud): Opens communication with computer Serial Monitor (e.g. Serial.begin(9600);).

4. Practical IoT Example: Automated LDR Streetlight

Here is a simple, complete Arduino sketch that turns an LED/Relay on pin 13 ON when it gets dark outside using an LDR light sensor on pin A0:

// Pin definitions
const int ldrPin = A0;          // Analog pin connected to LDR light sensor
const int ledPin = 13;          // Digital pin connected to Streetlight LED
const int lightThreshold = 400; // Darkness cutoff level

void setup() {
  pinMode(ledPin, OUTPUT);      // Pin 13 is set as an output
  Serial.begin(9600);           // Start Serial Monitor at 9600 baud rate
  Serial.println("Smart Streetlight System Initialized.");
}

void loop() {
  // Read light level (returns a number between 0 and 1023)
  int lightLevel = analogRead(ldrPin);
  
  // Show the reading on the computer screen
  Serial.print("Current Light Level: ");
  Serial.println(lightLevel);

  // If it is dark outside, turn the light ON
  if (lightLevel < lightThreshold) {
    digitalWrite(ledPin, HIGH); // Streetlight ON
    Serial.println("Darkness detected -> Light turned ON");
  } else {
    digitalWrite(ledPin, LOW);  // Streetlight OFF
    Serial.println("Daylight detected -> Light turned OFF");
  }

  delay(1000); // Wait 1 second before checking again
}

💡 DAVV Exam Preparation Tips

5-Mark Question: “Explain the memory architecture of ATmega328P on Arduino Uno.”

  • Flash Memory (32 KB): Non-volatile ROM that stores your compiled C/C++ program code (0.5 KB used by bootloader).
  • SRAM (2 KB): Volatile RAM that stores temporary runtime variables while running.
  • EEPROM (1 KB): Non-volatile storage that saves permanent settings (like user settings) even after power is turned OFF.

5-Mark Question: “What are PWM pins on Arduino Uno? How do they work?”

  • Pins: Pins 3, 5, 6, 9, 10, and 11 (marked with ~).
  • How it Works: Arduino cannot output true variable analog voltage. Instead, PWM rapidly pulses 5V ON and OFF. The ratio of ON time vs OFF time (Duty Cycle from 0 to 255) controls average voltage to dim LEDs or slow motors.

10-Mark Question: “Draw and explain the complete pinout and architecture of Arduino Uno. Explain the execution cycle of setup() and loop() with a practical interfacing code example.”

  • Draw the Arduino Uno block diagram (USB, DC power jack, ATmega328P, Reset button, Digital pins, Analog pins).
  • Explain the pin groups: 14 Digital pins, 6 PWM pins, 6 Analog pins (10-bit ADC), Power pins.
  • Explain setup() (runs once) and loop() (repeats endlessly).
  • Write out the complete working C/C++ code for the LDR automatic streetlight with comments.