EEE - Unit 1 - Notes Introduction To Arduino
EEE - Unit 1 - Notes Introduction To Arduino
Introduction to Arduino
CO1: APPLY programming concepts to UNDERSTAND role of Microprocessor and Microcontroller in embedded
systems
An introduction to microcontrollers and microprocessors:
Microcontrollers and microprocessors are fundamental components of modern computing and embedded
systems. These compact integrated circuits serve as the brains of various devices, enabling them to process data
and perform tasks.
Microprocessors are central processing units (CPUs) that form the heart of computers. They execute instructions,
perform arithmetic and logic operations, and manage data flow within a system. Microprocessors are commonly
found in desktops, laptops, and servers, driving the entire range of computational tasks.
Microcontrollers, on the other hand, are more specialized devices designed to control and monitor specific
functions in embedded systems. They combine a CPU, memory, and various peripherals on a single chip, making
them suitable for applications where size, power efficiency, and cost are crucial. Microcontrollers power everyday
objects like washing machines, microwave ovens, and even complex systems like automotive control units.
Both microcontrollers and microprocessors play vital roles in shaping our technological landscape, powering
devices that range from simple to highly sophisticated.
1. Pin Mode: Before using a GPIO pin, you need to set its mode as either INPUT or OUTPUT using the
pinMode() function.
For example:
pinMode(13, OUTPUT); // Sets digital pin 13 as an output
pinMode(A0, INPUT); // Sets analog pin A0 as an input
2. Digital Write: For digital pins configured as OUTPUT, you can use the digitalWrite() function to set the
pin's state to HIGH or LOW:
3. Digital Read: For digital pins configured as INPUT, you can use the digitalRead() function to read the pin's
state:
int value = digitalRead(2); // Reads the state of digital pin 2 (HIGH or LOW)
4. Analog Read: For analog pins, you can use the analogRead() function to read the analog voltage and
convert it to a digital value:
int analogValue = analogRead(A0); // Reads the analog value from pin A0
5. Interrupts: GPIO pins can be configured to generate interrupts when their state changes. This is useful for
responding quickly to events. Arduino provides functions like attachInterrupt() to set up interrupt-driven
actions.