0% found this document useful (0 votes)
2K views

Integration of Sensors and Actuators With Arduino-: Dr. Sudip Misra

The document discusses integrating servo motors with Arduino. It describes how servo motors work and the basic servo library. A servo motor provides precise rotary motion from 0 to 180 degrees using 3 wires: ground, power, and signal. The Arduino servo library allows controlling the servo position by writing angle values. An example sketch shows attaching a servo to a pin and using write() to move it to 0, 90, and 180 degrees with delays.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views

Integration of Sensors and Actuators With Arduino-: Dr. Sudip Misra

The document discusses integrating servo motors with Arduino. It describes how servo motors work and the basic servo library. A servo motor provides precise rotary motion from 0 to 180 degrees using 3 wires: ground, power, and signal. The Arduino servo library allows controlling the servo position by writing angle values. An example sketch shows attaching a servo to a pin and using write() to move it to 0, 90, and 180 degrees with delays.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Integration of Sensors and Actuators with Arduino-

Part II
Dr. Sudip Misra
Associate Professor
Department of Computer Science and Engineering
IIT KHARAGPUR
Email: [email protected]
Website: http://cse.iitkgp.ac.in/~smisra/

Introduction to Internet of Things 1


Topics Covered

 Introduction to ACTUATOR
 Servo Motor
 Servo motor interfaced with Arduino
 Hardware interface
 Sketch

Introduction to Internet of Things 2


Actuators

 Mechanical/Electro-mechanical device
 Converts energy into motion
 Mainly used to provide controlled motion to other
components

Introduction to Internet of Things 3


Basic Working Principle

Uses different combination of various mechanical


structures like screws, ball bearings, gears to produce
motion.

Introduction to Internet of Things 4


Types of Motor Actuators

 Servo motor
 Stepper motor
 Hydraulic motor
 Solenoid
 Relay
 AC motor

Introduction to Internet of Things 5


Servo Motor
 High precision motor
 Provides rotary motion 0
to 180 degree
 3 wires in the Servo motor
 Black or the darkest one is
Ground
 Red is for power supply
 Yellow for signal pin

Introduction to Internet of Things 6


Servo Library on Arduino

 Arduino provides different library- SERVO


to operate the servo motor
 Create an instance of servo to use it in the
sketch
Servo myservo;

Introduction to Internet of Things 7


Sketch: SERVO_ACTUATOR
void loop(){
#include <Servo.h> //Servo moves to 0 degrees
//Including the servo library for the program ServoDemo.write(0);
int servoPin = 12; delay(1000);

// Servo moves to 90 degrees


Servo ServoDemo; // Creating a servo object
ServoDemo.write(90);
void setup() { delay(1000);
// The servo pin must be attached to the servo
before it can be used // Servo moves to 180 degrees

ServoDemo.attach(servoPin); ServoDemo.write(180);
delay(1000);
}
}

Introduction to Internet of Things 8


Sketch: SERVO_ACTUATOR (contd..)

 Create an instance of Servo


 The instance must be attached
to the pin before being used in
the code
 Write() function takes the
degree value and rotates the
motor accordingly

Introduction to Internet of Things 9


Connection

 Connect the Ground of the


servo to the ground of the
Arduino board.
 Connect the power supply wire
to the 5V pin of the board.
 Connect the signal wire to any
digital output pin (we have used
pin 8).

Introduction to Internet of Things 10


Board Setup

 Connect the board to the PC

 Set the port and board type

 Verify and upload the code

Introduction to Internet of Things 11


Output

The motor turns 0, 90 and 180


degrees with a delay of 1 second
each.

Introduction to Internet of Things 12


Do more with the Servo library

Some other functions available with the Servo


library:
 Knob()
 Sweep()
 write()
 writeMicroseconds()
 read()
 attached()
 detach()

Source: “Servo Library”, Arduino Home (Online), Link: www.arduino.cc/en/Reference/Servo

Introduction to Internet of Things 13


Introduction to Internet of Things 14

You might also like