Arduino


Arduino – Formal Definition
Arduino is an open-source electronics prototyping platform based on easy-to-use hardware and software. It consists of microcontroller-based boards that can read inputs from sensors or signals and convert them into outputs such as controlling LEDs, motors, or other actuators. The Arduino environment includes the Arduino IDE, which provides a programming interface using a simplified version of C/C++, and a toolchain for compiling and uploading code to the hardware. Its open-source nature, flexibility, and wide range of compatible shields and libraries make Arduino a widely used platform in embedded systems, IoT, robotics, and automation applications.



Arduino – Boards, Features, and Programming

Arduino is an open-source electronics platform used for building electronic projects. It consists of both hardware (Arduino boards) and software (Arduino IDE). The boards are based on microcontrollers that can read inputs from sensors and produce outputs like controlling LEDs, motors, or other devices.





Types of Arduino Boards

There are several types of Arduino boards, each designed for specific applications:

  1. Arduino UNO (R3)

    • Most commonly used board.
    • Based on ATmega328P microcontroller.
    • Consists of 14 digital I/O pins (6 support PWM), 6 analog inputs, USB connection, power jack, ICSP header, and reset button.
    • Operates with 16 MHz clock, 32 KB flash memory, and recommended voltage range 7–12V.
  2. Arduino Leonardo

    • Uses ATmega32u4 microcontroller with 20 I/O pins.
    • Can act as mouse or keyboard in computer systems.
    • Cheapest board with built-in USB communication.
  3. Arduino Mega (R3)

    • Based on ATmega2560 with 54 digital pins (14 PWM), 16 analog inputs, and 4 UARTs.
    • Provides 256 KB flash memory.
    • Suitable for complex projects requiring more memory and pins.
  4. Arduino Mini

    • Small version of Arduino UNO with limited features.
    • Suitable for compact embedded applications.
  5. LilyPad Arduino

    • Designed for wearable electronics.
    • Circular board with sewable pads for stitching into clothing.
  6. Arduino RedBoard

    • Uses FTDI FT232RL USB-to-serial chip.
    • Compatible with Windows without changing security settings.
    • Reliable and beginner-friendly.
  7. Arduino Nano & Micro

    • Miniature boards based on ATmega328/ATmega32u4.
    • Used in space-constrained applications.
  8. Arduino Due

    • First ARM Cortex-M3-based board.
    • Operates at 84 MHz, has 54 digital I/O pins, 12 analog inputs, 2 DACs, USB OTG, and higher performance.

Main Features of Arduino UNO

  • Power Supply (USB/Barrel Jack): Can be powered by USB or external adapter (7–12V recommended).
  • Pins:
    • GND – Ground pins.
    • 5V & 3.3V – Power output pins.
    • Analog Pins (A0–A5) – Read analog input signals.
    • Digital Pins (0–13) – Used for input/output.
    • PWM Pins (~) – Provide analog-like output using Pulse Width Modulation.
    • AREF – Analog reference voltage.
  • Reset Button: Restarts the program on the board.
  • LED Indicators:
    • Power LED (ON).
    • TX/RX LEDs for data transmission/reception.
  • Main IC (ATmega328P): Acts as the brain of the board.
  • Voltage Regulator: Protects the board from high voltages.

Arduino Program Structure

Programs in Arduino are called Sketches (saved with .ino extension).

  1. Structure:

    • setup() → Initializes variables, pin modes, and libraries. Runs once at startup.
    • loop() → Executes repeatedly, controlling the board continuously.
  2. Control Structures: if, if-else, switch, for, while, do-while, break, continue.

  3. Variables and Constants:

    • Constants: HIGH, LOW, INPUT, OUTPUT, TRUE, FALSE.
    • Data types: int, float, boolean, char, byte, void.
  4. Functions:

    • Digital I/O: pinMode(), digitalRead(), digitalWrite()
    • Analog I/O: analogRead(), analogWrite(), analogReference()

Arduino Toolchain (IDE)

Arduino uses an IDE (Integrated Development Environment) that includes a hidden toolchain for compiling and uploading sketches.

  • Steps:

    1. Preprocessor assembles the sketch files.
    2. GCC compiler converts source code into machine code.
    3. Linker combines object files into an executable.
    4. AVRDUDE uploads the hex file into Arduino flash memory.
  • IDE Functions:

    • New → Create a sketch.
    • Open → Load an existing sketch.
    • Save → Save current sketch.
    • Verify → Check for errors.
    • Upload → Send code to Arduino board.

Example Program – Blink LED

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

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

Arduino Shields

Shields are add-on boards mounted on Arduino to expand its capabilities.

  • Examples:
    • Ethernet Shield – Connects Arduino to the internet.
    • Motor Shield – Controls motors.
    • Proto Shield – Allows custom circuit soldering.
    • Joystick Shield – Provides game controller functionality.
  • Shields are detachable, stackable, and make circuits compact.

Key Advantages of Arduino

  • Simple USB interface for programming.
  • Open-source design with large community support.
  • Uses ATmega microcontrollers with timers, interrupts, and sleep modes.
  • Provides sufficient memory and 16 MHz clock for most applications.
  • Supports multiple libraries and external modules.







Arduino – Topics

  • Introduction to Arduino
  • Types of Arduino Boards
    • Arduino UNO
    • Arduino Leonardo
    • Arduino Mega
    • Arduino Mini
    • LilyPad Arduino
    • Arduino RedBoard
    • Arduino Nano & Micro
    • Arduino Due
  • Main Features of Arduino UNO
  • Arduino Pins and Functions
  • Arduino Program Structure
    • setup()
    • loop()
  • Arduino Control Structures
  • Variables, Constants, and Data Types
  • Arduino Functions
    • Digital I/O Functions
    • Analog I/O Functions
  • Arduino Toolchain (IDE)
  • Arduino IDE Functions
  • Example Program (Blink LED)
  • Arduino Shields
    • Ethernet Shield
    • Motor Shield
    • Proto Shield
    • Joystick Shield
  • Advantages of Arduino