0% found this document useful (0 votes)
15 views

Sutrpath

The document provides an overview of Arduino, detailing its key components, features, and applications. It explains the specifications of the Arduino Uno R3 microcontroller and outlines various programming functions available in Arduino, including digital I/O, analog I/O, timer, advanced I/O, communication, interrupt, and math functions. Additionally, it includes example code for blinking an LED and creating a sine wave to control LED brightness.

Uploaded by

Anuja Binnar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Sutrpath

The document provides an overview of Arduino, detailing its key components, features, and applications. It explains the specifications of the Arduino Uno R3 microcontroller and outlines various programming functions available in Arduino, including digital I/O, analog I/O, timer, advanced I/O, communication, interrupt, and math functions. Additionally, it includes example code for blinking an LED and creating a sine wave to control LED brightness.

Uploaded by

Anuja Binnar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

UNIT 3:Getting Started With Arduino

Q. What are key components of Arduino.


Q. List the features of Arduino.

Arduino is composed of two major parts:


1. The Arduino board, which is a piece of hardware you work on when you
build your objects.
2. The Arduino IDE, which is a piece of software you run on your
computer. You use the IDE to create a sketch (a small computer program)
that you upload to the Arduino board.
Arduino is different from other platforms in the market because of the
following features

1. It is a multiplatform environment; it can run on Windows, Macintosh,


and Linux.
2. It is based on a processing programming IDE, which is an easy-to-use
development environment used by artists and designers.
3. You program it via a USB cable, not a serial port. This feature is useful,
because many modern computers do not have serial ports.
4. It is open-source hardware and software—if you wish, you can
download the circuit diagram, buy all the components, and make your own
Arduino board,without paying anything to the makers of Arduino.
5. The hardware is cheap.
6. There is an active community of users, so there are many people who
can assist you.
7. The Arduino project was developed in an educational environment, and
is therefore, great for newcomers to get things working quickly.

Q. List the applications of Arduino.


1. Real-world monitoring
• Automated weather station
• Lightning detection
• Automatic wildlife detector
• Home or business security system
2. Small-scale control
• Small robots
• Model rockets
• Model aircrafts

3. Small-scale Automation
• Automated aquarium
• Precision thermal chamber
• Automated electronic test system
4. Performance Art
• Dynamic lighting control
• Dynamic sound control
• Audience responsive artwork

Q. Explain Arduino Uno R3 with its specifications.

 Microcontroller:
The heart of the Arduino Uno R3 is the ATmega328P, an 8-bit
AVR(developed by atmel organization) microcontroller with low power
consumption and high performance.

 Input/Output Pins:

 Digital Pins: 14 digital I/O pins (0–13)


 Analog Pins: 6 analog input pins (A0–A5) for reading sensor data
like temperature, light intensity, etc.

 Power Supply Options:

 Powered via USB (5V) or an external power supply (7–12V ).


 Includes a voltage regulator to maintain stable operation.

 USB Interface:

 Facilitates communication between the board and a computer for


programming and data exchange.
 Uses the ATmega16U2 chip to act as a USB-to-serial converter.

 Clock Speed:
Operates at a clock frequency of 16 MHz, providing sufficient speed for
most applications.

 Memory:

 Flash Memory: 32 KB (0.5 KB is used for the bootloader).


 SRAM: 2 KB for dynamic data storage.
 EEPROM: 1 KB for permanent data storage.
 Connectivity:
The board supports serial communication through UART, SPI, and I2C
protocols, enabling connections to various modules and devices like
sensors, displays, and motors.

 Reset Button:
Includes a reset button to restart the program or hardware if needed.

 Size:
Compact dimensions of 68.6 mm x 53.4 mm, making it portable and easy
to integrate into projects.

Q. Explain the following functions w.r.t Arduino Programming.

Here’s a detailed explanation of the various functions available in


Arduino:

1. Digital I/O Functions

Digital I/O functions control the digital pins of the Arduino board. These
pins can either act as inputs (to read data) or outputs (to send data).

Common Functions:

 pinMode(pin, mode):
Configures a specific pin as an INPUT, OUTPUT
 Example: pinMode(13, OUTPUT);
 digitalWrite(pin, value):
Sets a digital pin to HIGH (5V) or LOW (0V).
Example: digitalWrite(13, HIGH);
 digitalRead(pin):
Reads the state of a digital pin, returning either HIGH or LOW.
Example: int buttonState = digitalRead(7);

2. Analog I/O Functions

Arduino has analog pins (e.g., A0–A5) for reading varying voltages and
writing simulated analog output using Pulse Width Modulation (PWM).

Common Functions:

 analogRead(pin):
Reads the input voltage on an analog pin and returns a value
between 0 and 1023, corresponding to 0V–5V.
Example: int sensorValue = analogRead(A0);
 analogWrite(pin, value):
Writes a PWM signal to a digital pin configured for PWM (e.g., pins
3, 5, 6, 9, 10, 11 on Uno). The value ranges from 0 to 255.
Example: analogWrite(9, 128);

3. Timer Functions

Timers are used for time-based tasks like delays, blinking LEDs, or
measuring time.

Common Functions:

 delay(milliseconds):
Pauses the program for a specified number of milliseconds.
Example: delay(1000); // Pause for 1 second
 millis():
Returns the number of milliseconds since the program started
running.
Example: unsigned long currentTime = millis();
 micros():
Returns the number of microseconds since the program started.
Example: unsigned long timeMicros = micros();
 delayMicroseconds(us):
Pauses the program for a specified number of microseconds.
Example: delayMicroseconds(500); // Pause for 0.5 ms

4. Advanced I/O Functions

Advanced I/O Functions in Arduino (Detailed Explanation)

Advanced I/O functions allow for more sophisticated control of


input/output operations in Arduino. These functions extend beyond basic
digital and analog operations, enabling interaction with more complex
hardware like shift registers, servos, and precise signal generation.

1. shiftOut(dataPin, clockPin, bitOrder, value)

The shiftOut function is used to send data one bit at a time to devices like
shift registers or LED drivers. It works by toggling a data pin and a clock
pin in synchronization.

Parameters:

 dataPin: Pin where the data is sent.


 clockPin: Pin that sends clock pulses to synchronize data.
 bitOrder: Defines whether the data is sent MSBFIRST (Most
Significant Bit First) or LSBFIRST (Least Significant Bit First).
 value: The data (byte) to send, typically in the range 0–255.

2. pulseIn(pin, value, timeout)

The pulseIn function measures the duration of a pulse (in microseconds)


on a digital pin. It is commonly used to read signals from devices like
ultrasonic sensors.

Parameters:
 pin: The digital pin to read the pulse from.
 value: The pulse level to detect (HIGH or LOW).
 timeout (optional): The maximum time (in microseconds) to wait
for the pulse. If not provided, defaults to 1 second.

3. tone(pin, frequency, duration)

The tone function generates a square wave at a specified frequency on a


digital pin, which can produce sound when connected to a speaker.

Parameters:

 pin: The pin where the tone will be generated.


 frequency: The frequency of the tone in Hertz (Hz).
 duration (optional): The duration of the tone in milliseconds. If not
provided, the tone will play indefinitely.

Example:

void setup() {
tone(8, 1000, 500); // Generate a 1 kHz tone for 500 ms
}

Note:

If you want to stop a tone, use the noTone(pin) function.

4. noTone(pin)

The noTone function stops the tone generated on a specific pin.

5. Communication Functions

Arduino supports multiple communication protocols for connecting with


other devices.

Serial Communication (UART):


 Serial.begin(baudRate):
Initializes serial communication at a specified baud rate.
Example: Serial.begin(9600);
 Serial.print(data):
Sends data to the Serial Monitor.
Example: Serial.print("Hello");
 Serial.read():
Reads incoming serial data.
Example: char data = Serial.read();

6. Interrupt Functions

Interrupts allow the Arduino to respond to specific events immediately,


bypassing the normal program flow.

Common Functions:

 attachInterrupt(digitalPinToInterrupt(pin), ISR, mode):


Associates an interrupt service routine (ISR) with a pin and trigger
mode (RISING, FALLING, or CHANGE).

Parameters:

1. digitalPinToInterrupt(pin):
Converts a digital pin number into an interrupt number .
2. ISR (Interrupt Service Routine):
A function (defined by the user) that will be executed when the
interrupt is triggered.
3. mode:
Defines the condition that triggers the interrupt:
o LOW: Trigger the interrupt when the pin is LOW.
o CHANGE: Trigger the interrupt when the pin changes state
(from HIGH to LOW or vice versa).
o RISING: Trigger the interrupt when the pin transitions from
LOW to HIGH.
o FALLING: Trigger the interrupt when the pin transitions from
HIGH to LOW.
 detachInterrupt(digitalPinToInterrupt(pin)):
Disables the interrupt on a specific pin.
Example: detachInterrupt(digitalPinToInterrupt(2));

7. Math Functions

Math functions are used for performing calculations in Arduino programs.

Common Functions:

 min(x, y) / max(x, y):


Returns the minimum or maximum value of two numbers.
Example: int smallest = min(10, 20);
 abs(x):
Returns the absolute value of a number.
Example: int absoluteValue = abs(-5);
 sqrt(x):
Returns the square root of a number.
Example: float root = sqrt(16);
 pow(base, exponent):
Raises a number to the power of another.
Example: float result = pow(2, 3);
 map(value, fromLow, fromHigh, toLow, toHigh):
Maps a number from one range to another.
Example: int mappedValue = map(50, 0, 100, 0, 255);

 Input value: 50
 Input range: 0–100
 Output range: 0–255

50 lies exactly halfway in the input range, so it maps to 127.5


(rounded to 127) in the output range.
Q. Write the code for Blinking LED example.
void setup() {
pinMode(13, OUTPUT); // Set digital pin 13 as an output
}

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

Q. Write a program to create a sine wave to control the brightness of LED


following the wave.

You might also like