ARDUINO AND RASPBERRY PI Unit 6
ARDUINO DEFINITION
Arduino is an open-source electronics platform based on easy-to-use hardware and software.
It consists of a microcontroller board (hardware) and an Integrated Development Environment
(IDE) used to write and upload code to the physical board. Unlike a full computer, Arduino is
designed for dedicated tasks—reading sensors, controlling motors, and interacting with the
physical world with very low latency.
ARDUINO ARCHITECTURE:
Arduino’s processor basically uses the Harvard architecture where the program code and
program data have separate memory. It consists of two memories- Program memory and the
data memory.
The code is stored in the flash program memory, whereas the data is stored in the data
memory.
The Atmega328 has 32 KB of flash memory for storing code (of which 0.5 KB is used for the
bootloader), 2 KB of SRAM and 1 KB of EEPROM and operates with a clock speed of 16MHz.
Arduino architecture consists of:
4. Power Supply
1. Microcontroller
Can be powered via:
The “brain” of Arduino USB
External adapter (7–12V)
Example: ATmega328P (in Arduino Uno)
Voltage regulation circuit ensures stable supply
Executes stored program 5. Clock (Oscillator)
2. Digital I/O Pins Typically 16 MHz crystal oscillator
Typically 14 digital pins (0–13) Controls timing of operations
6. Communication Interfaces
Can act as:
Input (read signals) UART (Serial communication)
Output (control devices) SPI (Serial Peripheral Interface)
I2C (Inter-Integrated Circuit)
3. Analog Input Pins
7. Memory Units
Usually 6 analog pins (A0–A5) Flash Memory (Program storage)
Used to read analog signals (0–1023 values) SRAM (Temporary data)
EEPROM (Permanent data storage)
ARDUINO PIN DIAGRAM
Arduino Uno consists of 14 digital input/output pins (of which 6 can be used as PWM outputs),
6 analog inputs, a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header,
and a reset button
Power Jack: Arduino can be power either from the pc through a USB or through external
source like adaptor or a battery. It can operate on a external supply of 7 to 12V. Power can
be applied externally through the pin Vin or by giving voltage reference through the IORef pin.
Digital Inputs: It consists of 14 digital inputs/output pins, each of which provide or take up
40mA current. Some of them have special functions like pins 0 and 1, which act as Rx and Tx
respectively , for serial communication, pins 2 and 3-which are external interrupts, pins
3,5,6,9,11 which provides pwm output and pin 13 where LED is connected.
Analog inputs: It has 6 analog input/output pins, each providing a resolution of 10 bits.
ARef: It provides reference to the analog inputs
Reset: It resets the microcontroller when low.
PROGRAMMING IN ARDUINO
The most important advantage with Arduino is the programs can be directly loaded to the
device without requiring any hardware programmer to burn the program. This is done
because of the presence of the 0.5KB of Bootloader which allows the program to be burned
into the circuit. All we have to do is to download the Arduino software and writing the code.
The Arduino tool window consists of the toolbar with the buttons like verify, upload, new,
open, save, serial monitor. It also consists of a text editor to write the code, a message area
which displays the feedback like showing the errors, the text console which displays the
output and a series of menus like the File, Edit, Tools menu.
Programs written in Arduino are known as sketches. A basic sketch consists of 3 parts
1. Declaration of Variables
2. Initialization: It is written in the setup () function.
3. Control code: It is written in the loop () function.
PROGRAMMING IN ARDUINO
Every Arduino program has two main functions:
setup(): Runs once when the board is powered on or reset. Used for initialization.
loop(): Runs continuously after setup finishes. Contains the main logic.
BASIC EXAMPLE (LED BLINKING)
Explanation:
pinMode() → Defines pin as input/output
digitalWrite() → Sets HIGH/LOW
delay() → Wait time in milliseconds
FEW OF BASIC ADRUINO FUNCTIONS
ARE:
digitalRead(pin): Reads the digital value at the given pin.
digitalWrite(pin, value): Writes the digital value to the given pin.
pinMode(pin, mode): Sets the pin to input or output mode.
analogRead(pin): Reads and returns the value.
analogWrite(pin, value): Writes the value to that pin.
[Link](baud rate): Sets the beginning of serial communication by setting the bit rate.
ARDUINO APPLICATIONS
1 Home Automation 4 Robotics
Control lights, fans, appliances Robot movement control
IoT-based smart homes Sensor-based navigation
Example: Smart lighting system using sensors Example: Line-following robot
2 Healthcare Systems 5 Environmental Monitoring
Patient monitoring systems Air quality monitoring
Heart rate, temperature sensors Water quality measurement
Example: Wearable health monitoring device Example: Smart pollution monitoring system
3 Industrial Automation 6 Smart Agriculture
Machine control Soil moisture monitoring
Process monitoring Automated irrigation systems
Example: Automated conveyor system Example: IoT-based smart irrigation
RASPBERRY PI
The Raspberry Pi is a series of small Single-Board Computers (SBCs). Unlike the Arduino,
which is a microcontroller, the Raspberry Pi runs a full operating system (usually Linux based,
like Raspberry Pi OS). It has a processor, memory, and graphics driver, allowing it to drive an
HDMI display, connect to the internet via WiFi/Ethernet, and run complex software like Python,
web servers, or even Minecraft.
It is a credit card-sized computer that can be plugged into a monitor. It acts as a
minicomputer by connecting the keyboard, mouse, and display. Raspberry Pi has an ARM
processor and 512MB of RAM.
ARCHITECTURE OF RASPBERRY PI
Raspberry Pi mainly consists of the following blocks:
Processor: Raspberry Pi uses Broadcom BCM2835 system on chip which is an ARM processor
and Video core Graphics Processing Unit (GPU). It is the heart of the Raspberry Pi which
controls the operations of all the connected devices and handles all the required computations.
HDMI: High Definition Multimedia Interface is used for transmitting video or digital audio data
to a computer monitor or to digital TV. This HDMI port helps Raspberry Pi to connect its signals
to any digital device such as a monitor digital TV or display through an HDMI cable.
GPIO ports: General Purpose Input Output ports are available on Raspberry Pi which allows
the user to interface various I/P devices.
Audio output: An audio connector is available for connecting audio output devices such as
headphones and speakers.
USB ports: This is a common port available for various peripherals such as a mouse, keyboard,
or any other I/P device. With the help of a USB port, the system can be expanded by
connecting more peripherals.
SD card: The SD card slot is available on Raspberry Pi. An SD card with an operating system
installed is required for booting the device.
Ethernet: The ethernet connector allows access to the wired network, it is available only on the
model B of Raspberry Pi.
Power supply: A micro USB power connector is available onto which a 5V power supply can be
connected.
Camera module: Camera Serial Interface (CSI) connects the Broadcom processor to the Pi
camera.
Display: Display Serial Interface (DSI) is used for connecting LCD to Raspberry Pi using 15 15-
pin ribbon cables. DSI provides a high-resolution display interface that is specifically used for
sending video data.
PROGRAMMING
Since Raspberry Pi runs Linux, it supports virtually any programming language (C, C++, Java,
JavaScript, Go). However, Python is the preferred educational language and has robust
libraries for controlling the hardware GPIO pins.
Example: Blinking an LED with Python (GPIO Zero Library)
APPLICATION OF RASPBERRY PI
Smart Home Hub: Home Assistant or OpenHAB to manage lights, heating, and security,
improving energy efficiency and security.
Media Center: Plex or Kodi server to stream movies, music, and photos.
Retro Gaming Console: Using platforms like RetroPie to emulate classic console games.
Networking Utilities: Pi-hole to block ads network-wide, or a VPN server for secure remote
access.
Desktop PC & Productivity: Basic computing for web browsing, document editing, and image
manipulation (LibreOffice, GIMP).
Robotics Controller: Using GPIO pins to control motors, sensors, and cameras for AI-powered
robots.
THANK YOU