You are on page 1of 27

lOMoARcPSD|27859431

ARDUINO

Arduino was created in the year 2005 by two Italian engineers David Cuartielles and Massimo Banzi with
the goal of encouraging students to program the Arduino uno microcontroller and improve their skills
about electronics and use it in the real world.
The Arduino Uno is a microcontroller board based on the ATmega328. It has 14 digital input/output pins,
6 analog inputs, a 16 MHz crystal oscillator, a USB connection, a power jack, memory and a reset
button. It contains everything needed to support the microcontroller; simply connect it to a computer
with a USB cable or power it with a AC-to-DC adapter or battery to get started.
Arduino uno microcontroller can sense the environment by receiving input from a variety of sensors and
can affect its surroundings by controlling lights, motors, and other actuators. The microcontroller is
programmed using the Arduino programming language and the Arduino development environment
."Uno" means one in Italian and is named to mark the version, Arduino 1.0. The Arduino IDE is derived
from Wiring and Processing.

Advantages of using Arduino:-


1. Inexpensive - Arduino boards are relatively inexpensive compared to other microcontroller
platforms.
2. Cross-platform - The Arduino Software (IDE) runs on Windows, Macintosh OSX, and Linux
operating systems.
3. Simple, clear programming environment - The Arduino Software (IDE) is easy-to-use for
beginners, yet flexible enough for advanced users.
4. Open source and extensible software - The Arduino software is published as open source tools,
available for extension by experienced programmers.
5. Open source and extensible hardware - The plans of the Arduino boards are published under a
Creative Commons license, so experienced circuit designers can make their own version of the
module, extending it and improving it.

Features of the Arduino Uno Board


● It has an easy USB interface. This allows interface with USB as this is like a serial device.
● It is very convenient to manage power inside it and it has a feature of built-in voltage regulation.
This can also be powered directly off a USB port without any external power. You can connect an
external power source of upto 12v and this regulates it to both 5v and 3.3v.
● 13 digital pins and 6 analog pins. This sort of pins allows you to connect hardware to your
Arduino Uno board externally.
● It has a 32 KB of flash memory for storing your code.
● An on-board LED is attached to digital pin 13 to make fast the debugging of code and to make
the debug process easy.
● It has a button to reset the program on the chip.
● It is a 16 MHz clock which is fast enough for most applications and does not speeds up the
microcontroller.

1
Downloaded by harish hari (cb105ec021@gmail.com)
lOMoARcPSD|27859431

● This has an ICSP (In-Circuit Serial Programming) connector for bypassing the USB port and
interfacing the Arduino directly as a serial device. This port is necessary to re-bootload your chip
if it corrupts and can no longer be connected to your computer.

❏ ARDUINO - BOARD DESCRIPTION

Power USB
Arduino board can be powered by using the USB cable from your computer. All you
need to do is connect the USB cable to the USB connection (1).

Power (Barrel Jack)


Arduino boards can be powered directly from the AC mains power supply by
connecting it to the Barrel Jack (2).

Voltage Regulator
The function of the voltage regulator is to control the voltage given to the Arduino
board and stabilize the DC voltages used by the processor and other elements.

Crystal Oscillator
The crystal oscillator helps Arduino in dealing with time issues. How does Arduino
calculate time? The answer is, by using the crystal oscillator. The number printed

2
Downloaded by harish hari (cb105ec021@gmail.com)
lOMoARcPSD|27859431

on top of the Arduino crystal is 16.000H9H. It tells us that the frequency is


16,000,000 Hertz or 16 MHz.

Arduino Reset
You can reset your Arduino board, i.e., start your program from the beginning. You
can reset the UNO board in two ways. First, by using the reset button (17) on the
board. Second, you can connect an external reset button to the Arduino pin
labelled RESET (5).

Pins (3.3, 5, GND, Vin)

● 3.3V (6) − Supply 3.3 output volt


● 5V (7) − Supply 5 output volt
● Most of the components used with Arduino board works fine with 3.3 volt
and 5 volt.
● GND (8)(Ground) − There are several GND pins on the Arduino, any of which
can be used to ground your circuit.
● Vin (9) − This pin also can be used to power the Arduino board from an
external power source, like AC mains power supply.

Analog pins
The Arduino UNO board has five analog input pins A0 through A5. These pins can
read the signal from an analog sensor like the humidity sensor or temperature
sensor and convert it into a digital value that can be read by the microprocessor.

Main microcontroller
Each Arduino board has its own microcontroller (11). You can assume it as the brain
of your board.

ICSP pin
ICSP (In-Circuit Serial Programming) pins are for bypassing the USB port and
interfacing the Arduino directly as a serial device. This port is necessary to
re-bootload your chip if it corrupts and can no longer be connected to your
computer.

Power LED indicator


This LED should light up when you plug your Arduino into a power source to
indicate that your board is powered up correctly. If this light does not turn on, then
there is something wrong with the connection.

3
Downloaded by harish hari (cb105ec021@gmail.com)
lOMoARcPSD|27859431

TX and RX LEDs
On your board, you will find two labels: TX (transmit) and RX (receive). They appear
in two places on the Arduino UNO board. First, at the digital pins 0 and 1, to
indicate the pins responsible for serial communication. Second, the TX and RX led
(13). The TX led flashes with different speed while sending the serial data. The
speed of flashing depends on the baud rate used by the board. RX flashes during
the receiving process.

Digital I/O
The Arduino UNO board has 14 digital I/O pins (15) (of which 6 provide PWM (Pulse
Width Modulation) output. These pins can be configured to work as input digital
pins to read logic values (0 or 1) or as digital output pins to drive different modules
like LEDs, relays, etc. The pins labeled “~” can be used to generate PWM.

AREF
AREF stands for Analog Reference. It is sometimes used to set an external
reference voltage (between 0 and 5 Volts) as the upper limit for the analog input
pins.

ARDUINO Terminology :-

Create, upload and save sketches using Arduino IDE -


Once the software starts, you have two options −

● Create a new project.


● Open an existing project example.

To create a new project, select File → New.

4
Downloaded by harish hari (cb105ec021@gmail.com)
lOMoARcPSD|27859431

To open an existing project example, select File → Example → Basics → Blink.

Here, we are selecting just one of the examples with the name Blink. It turns the LED on and off with
some time delay. You can select any other example from the list.

● Select your Arduino board.

To avoid any error while uploading your program to the board, you must select the correct Arduino
board name, which matches with the board connected to your computer.

Go to Tools → Board and select your board.

5
Downloaded by harish hari (cb105ec021@gmail.com)
lOMoARcPSD|27859431

Here, we have selected the Arduino Uno board according to our tutorial, but you must select the name
matching the board that you are using.

● Select your serial port.


Select the serial device of the Arduino board. Go to Tools → Serial Port/Port menu. This is likely to be
COM3 or higher (COM1 and COM2 are usually reserved for hardware serial ports). To find out, you can
disconnect your Arduino board and re-open the menu, the entry that disappears should be of the
Arduino board. Reconnect the board and select that serial port.

6
Downloaded by harish hari (cb105ec021@gmail.com)
lOMoARcPSD|27859431

● Upload the program to your board.

Before explaining how we can upload our program to the board, we must demonstrate the function of
each symbol appearing in the Arduino IDE toolbar.

A − Used to check if there is any compilation error.

7
Downloaded by harish hari (cb105ec021@gmail.com)
lOMoARcPSD|27859431

B − Used to upload a program to the Arduino board.

C − Shortcut used to create a new sketch.

D − Used to directly open one of the example sketches.

E − Used to save your sketch.

F − Serial monitor used to receive serial data from the board and send the serial data to the board.

Now, simply click the "Upload" button in the environment. Wait a few seconds; you will see the RX and
TX LEDs on the board, flashing. If the upload is successful, the message "Done uploading" will appear
in the status bar.

PROGRAMMING WITH ARDUINO

Arduino programs can be divided into three main parts: Structure, Values (variables and constants),
and Functions.

Let us start with the Structure. Software structure consist of two main functions −

● Setup function- The setup() function is called when a sketch starts. Use it to initialize the

variables (not declaration), pin modes, start using libraries, etc. The setup function will only run

once, after each power up or reset of the Arduino board.

● Loop function - After creating a setup() function, which initializes and sets the initial values, the

loop() function does precisely what its name suggests, and loops consecutively, allowing your

program to change and respond. Use it to actively control the Arduino board.

Data Types -

The following table provides all the data types that you will use during Arduino programming.

Data void bool unsi int unsi word long unsi float doub strin struc array enum pointer

type ean gned gned gned le g t

char int long

8
Downloaded by harish hari (cb105ec021@gmail.com)
lOMoARcPSD|27859431

RAM N/A 1byte 1 2 2 2 4 4 4 4 1 N/A 1 N/A N/A

usag byte byte byte byte byte byte byte byte byte byte

e +x +x

Control Statements are elements in Source Code that control the flow of program execution. They
are −

S.N Control Statement & Description Syntax


o

If statement
It takes an expression in parenthesis and
a statement or block of statements. If the if (expression)
expression is true then the statement or
{
block of statements gets executed
otherwise these statements are skipped. Block of statements;
1 }

If …else statement
An if statement can be followed by an
optional else statement, which executes if (expression) {
when the expression is false.
Block of statements;
2 }

else {

Block of statements;

9
Downloaded by harish hari (cb105ec021@gmail.com)
lOMoARcPSD|27859431

If…else if …else statement


The if statement can be followed by an
optional else if...else statement, which is if (expression_1) {
very useful to test various conditions
Block of statements;
using single if...else if statement.
}

else if(expression_2) {

Block of statements;
3 }

else {

Block of statements;

10
Downloaded by harish hari (cb105ec021@gmail.com)
lOMoARcPSD|27859431

Switch Case statement


Similar to the if statements, switch...case
controls the flow of programs by allowing switch (variable) {
the programmers to specify different
case label:
codes that should be executed in various
conditions. // statements

break;

case label: {

// statements
4
break;

default: {

// statements

break;

Conditional Operator ? :
The conditional operator ? : is the only
ternary operator in C. expression1 ? expression2 : expression3
5

Programming languages provide various control structures that allow for more complicated execution
paths.

A loop statement allows us to execute a statement or group of statements multiple times.

S.N Loop & Description Syntax


O.

11
Downloaded by harish hari (cb105ec021@gmail.com)
lOMoARcPSD|27859431

while loop
while loops will loop continuously, and infinitely, while(expression) {
1 until the expression inside the parenthesis, () Block of statements;
becomes false. Something must change the }
tested variable, or the while loop will never exit.

do…while loop do {
The do…while loop is similar to the while loop. In Block of statements;
the while loop, the loop-continuation condition is }
2 tested at the beginning of the loop before while (expression);
performed the body of the loop.

for loop for ( initialize; control; increment or


A for loop executes statements a predetermined decrement) {
3 number of times. The control expression for the // statement block
loop is initialized, tested and manipulated entirely }
within the for loop parentheses.

Nested Loop for ( initialize ;control; increment or


You can use one loop inside another loop. The decrement) {
following example illustrates the concept. // statement block
for ( initialize ;control; increment
4 or decrement) {
// statement block
}
}

12
Downloaded by harish hari (cb105ec021@gmail.com)
lOMoARcPSD|27859431

Infinite loop for (; ;) {


It is the loop having no terminating condition, so // statement block
the loop becomes infinite. }
Or

while(1) { // 1 indicates always True


// statement block
5
}

Or
do {
Block of statements;
}
while(1);

ARDUINO I/O (Input, Output ) Functions -


1. pinMode() -The pinMode() function is used to configure a specific pin to behave either as an
input or an output.

● pin − the number of the pin whose


pinMode() Function Syntax mode you wish to set
void setup () ● mode − INPUT, OUTPUT, or
{ pinMode (pin , mode); } INPUT_PULLUP.

2. digitalWrite() - The digitalWrite() function is used to write a HIGH or a LOW value to a digital pin.

● pin − the number of the pin whose


digitalWrite() Function Syntax mode you wish to set
digitalWrite (pin ,value) ● value − HIGH, or LOW.
Example -
void loop()
{ digitalWrite (4 ,HIGH); }

3. digitalRead() -Reads the value from a specified digital pin, either HIGH or LOW.

13
Downloaded by harish hari (cb105ec021@gmail.com)
lOMoARcPSD|27859431

● pin - the number of the


digitalRead() Function Syntax digital pin you want to read
digitalRead(pin); (int).
Example -
void loop() Return -
{ ● val − HIGH, or LOW.
val = digitalRead(4); // read the input pin
digitalWrite(7, val); // sets the LED to the button's
value
}

4. analogRead( ) function - we can read the voltage applied to one of the pins. This function
returns a number between 0 and 1023, which represents voltages between 0 and 5 volts.

● analogPin − the number of the


analogRead() function Syntax analog input pin to read from (0 to 5
analogRead(analogPin); on most boards, 0 to 7 on the Mini
Example - and Nano, 0 to 15 on the Mega)
void loop() Return -
{ val = analogRead(analogPin); } ● int (0 to 1023)
5. analogWrite( ) function - Writes an analog value to a pin.

● Pin - the pin to write to.


analogWrite() function Syntax ● value - the duty cycle: between 0
(always off) and 255 (always on).
analogWrite(Pin, value)

Example -
void loop()
{

val = analogRead(Pin); // read the input pin

analogWrite(ledPin, val / 4); // analogRead


values go from 0 to 1023, analogWrite values
from 0 to 255

ARDUINO SERIAL COMMUNICATION -

14
Downloaded by harish hari (cb105ec021@gmail.com)
lOMoARcPSD|27859431

In telecommunication and data transmission, serial communication is the process of sending data one
bit at a time, sequentially, over a communication channel or computer bus. The Serial Monitor is a
separate pop-up window that acts as a separate terminal for communication.

The serial monitor is the 'tether' between the computer and your Arduino , it lets you send and receive
text messages, handy for debugging and also controlling the Arduino from a keyboard. For example,
you will be able to send commands from your computer to turn on LEDs.

The baud rate is the rate at which information is transferred in a communication channel. For
communicating with the computer, use baud rate: 9600 (transferring a maximum of 9600 bits per
second).

SERIAL COMMUNICATION FUNCTIONS -

print()- Example -
Prints data to the serial port as human-readable ASCII
text. 1.Serial.print(78) gives "78"
println()- 2.Serial.print(1.23456) gives "1.23"
Prints data to the serial port as human-readable ASCII
text followed by a carriage return character ( '\r') and 3.Serial.print('N') gives "N"
a newline character ('\n').
4.Serial.print("Hello world.") gives
Syntax - "Hello world."
Serial.print(val)
Serial.print(val, format)
Serial.println(val)
Serial.println(val, format)

Parameters -
val: the value to print - any data type.

begin() - Sets the data rate in bits per second (baud) Example -
for serial data transmission.
void setup() {
Syntax - Serial.begin(9600); // opens serial port, sets
data rate to 9600 bps
Serial.begin(speed) }
Serial.begin(speed, config)

Parameters -
speed: in bits per second (baud) - long

end() - Disables serial communication,To re-enable Example -


serial communication, call Serial.begin().
Serial.end()
Syntax -

15
Downloaded by harish hari (cb105ec021@gmail.com)
lOMoARcPSD|27859431

Serial.end()

For More Function Refer the link - https://www.arduino.cc/en/Reference/Serial

ARRAYS IN ARDUINO - An array is a collection of variables that are accessed with an index number .

Creating Array -
int myInts[6];
int myPins[] = {2, 4, 8, 3, 6};
int mySensVals[6] = {2, 4, -8, 3, 2};
char message[6] = "hello";

Internal Mapping of Array -


int C[] = { -45,6,0,72,1543,-89,0,62,-3,1,78 };

Example -

16
Downloaded by harish hari (cb105ec021@gmail.com)
lOMoARcPSD|27859431

/*
Arrays

Demonstrates the use of an array to hold pin numbers


in order to iterate over the pins in a sequence.
Lights multiple LEDs in sequence, then in reverse. */

int timer = 100; // The higher the number, the


slower the timing.
int ledPins[] = {2, 7, 4, 6, 5, 3}; // an array of pin
numbers to which LEDs are attached
int pinCount = 6; // the number of pins (i.e. the
length of the array)

void setup() {
// the array elements are numbered from 0 to (pinCount
- 1).
// use a for loop to initialize each pin as an output:
for (int thisPin = 0; thisPin < pinCount; thisPin++) {
pinMode(ledPins[thisPin], OUTPUT);
}
}

void loop() {
// loop from the lowest pin to the highest:
for (int thisPin = 0; thisPin < pinCount; thisPin++) {
// turn the pin on:
digitalWrite(ledPins[thisPin], HIGH);
delay(timer);
// turn the pin off:
digitalWrite(ledPins[thisPin], LOW);

// loop from the highest pin to the lowest:


for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--)
{
// turn the pin on:
digitalWrite(ledPins[thisPin], HIGH);
delay(timer);
// turn the pin off:
digitalWrite(ledPins[thisPin], LOW);
}
}

PROGRAMMING Examples :-

1. Example Blink

17
Downloaded by harish hari (cb105ec021@gmail.com)
lOMoARcPSD|27859431

Schematic- Sketch -
// Turns on an LED on for one second, then off for
one second, repeatedly.
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on
(HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off
by making the voltage LOW
delay(1000); // wait for a second
Hardware Requirements- }
Arduino Board
LED
390 ohm resistor

2. Example Fade-

Schematic- Sketch -
/* This example shows how to fade an LED on pin
9 using the analogWrite() function.
The analogWrite() function uses PWM, so if you want
to change the pin you're using, be sure to use
another PWM capable pin. On most Arduino, the
PWM pins are identified with a "~" sign, like ~3, ~5,
~6, ~9, ~10 and ~11.

18
Downloaded by harish hari (cb105ec021@gmail.com)
lOMoARcPSD|27859431

*/

int led = 9; // the PWM pin the LED is attached


to
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the
LED by

// the setup routine runs once when you press reset:


void setup() {
// declare pin 9 to be an output:
pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:


void loop() {
// set the brightness of pin 9:
analogWrite(led, brightness);

// change the brightness for next time through the


loop:
brightness = brightness + fadeAmount;

// reverse the direction of the fading at the ends of


the fade:
Hardware Requirements-
if (brightness <= 0 || brightness >= 255) {
Arduino or Genuino board fadeAmount = -fadeAmount;
}
LED
220 ohm resistor // wait for 30 milliseconds to see the dimming effect
delay(30);
hook-up wires }
breadboard

3. Example Detect Day Light (photoresistor) -

Schematic- Sketch -
// these constants won't change. They are the
// lowest and highest readings you get from your sensor:
const int sensorMin = 0; // sensor minimum, discovered
through experiment

19
Downloaded by harish hari (cb105ec021@gmail.com)
lOMoARcPSD|27859431

const int sensorMax = 600; // sensor maximum,


discovered through experiment

void setup() {
// initialize serial communication:
Serial.begin(9600);
}

void loop() {
// read the sensor:
int sensorReading = analogRead(A0);
// map the sensor range to a range of four options:
int range = map(sensorReading, sensorMin, sensorMax,
0, 3);

// do something different depending on the


// range value:
switch (range) {
case 0: // your hand is on the sensor
Serial.println("dark");
Hardware Requirements- break;
case 1: // your hand is close to the sensor
Arduino or Genuino Board Serial.println("dim");
break;
photoresistor, or another case 2: // your hand is a few inches from the sensor
analog Serial.println("medium");
break;
sensor case 3: // your hand is nowhere near the sensor
Serial.println("bright");
10k ohm resistors
break;
hook-up wires }
delay(1); // delay in between reads for stability
breadboard }

4. Example Push Button -

Schematic- Sketch -
// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2; // the number of the
pushbutton pin
const int ledPin = 13; // the number of the
LED pin

20
Downloaded by harish hari (cb105ec021@gmail.com)
lOMoARcPSD|27859431

// variables will change:


int buttonState = 0; // variable for reading the
pushbutton status

void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}

void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed.


Hardware Requirements- // if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
Arduino or Genuino Board // turn LED on:
Momentary button or Switch digitalWrite(ledPin, HIGH);
} else {
10K ohm resistor // turn LED off:
digitalWrite(ledPin, LOW);
hook-up wires }
breadboard }

5. Example Piezo Plate -

Schematic- Sketch -
// these constants won't change:
const int ledPin = 13; // led connected to
digital pin 13
const int knockSensor = A0; // the piezo is
connected to analog pin 0
const int threshold = 100; // threshold value to
decide when the detected sound is a knock or
not

// these variables will change:


int sensorReading = 0; // variable to store the
value read from the sensor pin

21
Downloaded by harish hari (cb105ec021@gmail.com)
lOMoARcPSD|27859431

int ledState = LOW; // variable used to store


the last LED status, to toggle the light

void setup() {
pinMode(ledPin, OUTPUT); // declare the ledPin
as as OUTPUT
Serial.begin(9600); // use the serial port
}

void loop() {
// read the sensor and store it in the variable
sensorReading:
sensorReading = analogRead(knockSensor);

// if the sensor reading is greater than the


threshold:
Hardware Requirements- if (sensorReading >= threshold) {
Arduino or Genuino Board // toggle the status of the ledPin:
ledState = !ledState;
8 ohm speaker // update the LED pin itself:
digitalWrite(ledPin, ledState);
photoresistor
// send the string "Knock!" back to the
4.7K ohm resistor computer, followed by newline
Serial.println("Knock!");
100 ohm resistor }
hook-up wires delay(100); // delay to avoid overloading the
serial port buffer
breadboard }

6. Example Reed Switch

Schematic- Sketch -
/* function:use a magnet to approach the reed switch, and
the LED light up. Move the magnet farther and the LED
will go out.
*/
const int digitalInPin = 7;// reed switch attach to pin7
const int ledPin = 13;// pin13 built-in led
void setup()
{
pinMode(digitalInPin,INPUT);// set digitalInPin as INPUT
pinMode(ledPin,OUTPUT); // set ledPin as OUTPUT
}

22
Downloaded by harish hari (cb105ec021@gmail.com)
lOMoARcPSD|27859431

void loop()
{
boolean stat = digitalRead(digitalInPin);//read the value of
pin7 to stat
if(stat == HIGH)// if it it HIGH
{
digitalWrite(ledPin,LOW);// then turn off the led
}
else //else
{
digitalWrite(ledPin,HIGH); // turn on the led
}
}

❏ Uses of the following Sensors -


1. PIR (passive infrared sensor) sensors allow you to sense motion. They are used to detect
whether a human has moved in or out of the sensor’s range. They are commonly found in appliances
and gadgets used at home or for businesses. They are often referred to as PIR, "Passive Infrared",
"Pyroelectric", or "IR motion" sensors.

Following are the advantages of PIR Sensors −

● Small in size

● Wide lens range

● Easy to interface

● Inexpensive

● Low-power

● Easy to use

● Do not wear out

2. Humidity Sensor -

23
Downloaded by harish hari (cb105ec021@gmail.com)
lOMoARcPSD|27859431

Following are the advantages of Humidity


Sensors −

● Senses and measures both moisture and


air temperature.

3. Photoresistor -

A photoresistor (or
light-dependent resistor, LDR, or
photoconductivecell) is a
light-controlled variable resistor.
The resistance of a photoresistor
decreases with increasing incident
light intensity. A photoresistor can
be applied in light-sensitive
detector circuits, and light- and
dark-activated switching circuits.

4. Accelerometer -

An accelerometer is a device that measures proper acceleration.[1]


Proper acceleration is the acceleration (or rate of change of velocity) of
a body in its own instantaneous rest frame.
Accelerometers have multiple applications in industry and science.
Highly sensitive accelerometers are components of inertial navigation
systems for aircraft and missiles. Accelerometers are used to detect
and monitor vibration in rotating machinery. Accelerometers are used in
tablet computers and digital cameras so that images on screens are
always displayed upright. Accelerometers are used in drones for flight
stabilisation.

5. SERVO Control -

24
Downloaded by harish hari (cb105ec021@gmail.com)
lOMoARcPSD|27859431

Arduino board to control RC (hobby) servo


motors. Servos have integrated gears and a shaft
that can be precisely controlled. Standard servos
allow the shaft to be positioned at various angles,
usually between 0 and 180 degrees. Continuous
rotation servos allow the rotation of the shaft to
be set to various speeds.

The Servo library supports up to 12 motors on


most Arduino boards and 48 on the Arduino
Mega. On boards other than the Mega, use of the
library disables analogWrite() (PWM) functionality
on pins 9 and 10, whether or not there is a Servo
on those pins. On the Mega, up to 12 servos can
be used without interfering with PWM
functionality; use of 12 to 23 motors will disable
PWM on pins 11 and 12.

Functions-
attach()
write()
writeMicroseconds()
read() FOR IMPLEMENTATION REFER BELOW GIVEN
LINK :
attached()
https://playground.arduino.cc/Learning/SingleSer
detach() voExample

Examples -

Knob: Control the position of a servo with


a potentiometer.
Sweep: Sweep the shaft of a servo motor
back and forth.

6. Other Important Sensors -

A proximity sensor is Soil moisture The Reed switch The Piezo buzzer is a
a sensor able to detect sensors measure (sometimes also known tiny speaker that

25
Downloaded by harish hari (cb105ec021@gmail.com)
lOMoARcPSD|27859431

the presence of nearby the volumetric as Herkon) is an electrical works on the principles
objects without any water content in switch operated by an of Piezoelectricity.
physical contact. soil applied magnetic field.It Certain crystals within
consists of a pair of the device change
contacts on shape when we apply
ferromagnetic metal electricity. By applying
reeds in a hermetically the electrical signal at
sealed glass envelope. the right frequency, a
The contacts may be sound can be
normally open, closing generated from the
when a magnetic field is crystal.
present, or normally
closed and opening when
a magnetic field is
applied.

7. PUSH Button and It’s Internal Connection-

Exercise Time
SHORT QUESTIONS
1. How many times does setup() run?
2. How many times does loop() run?
3. Expand PWM ?
4. PWM output varies from _ to _ ?
5. The digital pin (6,4,3,2) which does not have PWM capability is ?
6. How many analog ports does an Arduino have?
7. Which language is the Arduino IDE written in?
8. In delay(t); t is given in :_____ (sec, millisec,nanosec,microsec)
9. If Serial is begun with Serial.begin(9600); How much time will it take to send 2 ASCII characters?
( 1.667 millisecond,1.9220 millisecond,4.800 millisecond,1.9200 millisecond)

26
Downloaded by harish hari (cb105ec021@gmail.com)
lOMoARcPSD|27859431

10. Which of these is a not an analog input device (pressure sensor: servo,button,potentiometer)?
11. Which of these is an analog input device (pressure sensor,servo,button,LED)?
12. Which of these is an output device(pressure sensor,servo,button,Potentiometer)?
13. The Arduino IDE is derived from which programming languages?

LONG QUESTIONS
1. In your own words, what is a microcontroller?
2. Give three examples of things you can do with a microcontroller.
3. Where is the microcontroller on the Arduino board?
4. What are two good signs that a device has a microcontroller in it?
5. What do you use the Arduino pins for?
6. Where would you go on the Internet to get help with an Arduino problem?
7. What is the difference between the Arduino IDE and Board?
8. How will you know that your sketch is okay?
9. Name three things that contain microcontrollers.
10. What is the Arduino Playground ?
11. What does the IDE Verify button do?
12. How do you mark comments in your sketch?

27
Downloaded by harish hari (cb105ec021@gmail.com)

You might also like