C Experiment 4
C Experiment 4
Experiment - 4
Objectives –
Components Required –
1. Servo/Stepper Motor
2. Bread Board
3. 10K Ohm Resistance
4. Jumper Wire
5. Arduino Board
6. USB Cable
7. L293 Motor Driver (If motor is 12V)
A. Circuit Diagram:
B. Steps:
A servo motor has everything built in “a motor, a feedback circuit, and a motor driver”. It just needs
one power line, one ground, and one control pin.
1. The servo motor has a female connector with three pins. The darkest or even black one is
usually the ground. Connect this to the Arduino GND.
2. Connect the power cable that in all standards should be red to 5V on the Arduino.
3. Connect the remaining line on the servo connector to a digital pin on the Arduino.
C. Code:
• Servo Servo1;
• void setup()
• {
• // We need to attach the servo to the used pin number
• Servo1.attach(servoPin);
• }
• void loop()
• {
• // Make servo go to 0 degrees
• Servo1.write(0);
• delay(1000);
• // Make servo go to 90 degrees
• Servo1.write(90);
• delay(1000);
• // Make servo go to 180 degrees
• Servo1.write(180);
• delay(1000);
• }
Additional Tasks –
1. Control position of a servo motor using potentiometer. Also, provide circuit diagram for the
same.
2. Angle control of a steeper motor during clockwise (10 to 180) and anticlockwise (180 to 10)
rotation.
Conclusions –
The DC motor speed control is an important task to control various robotics systems. In this experiment
students have gained knowledge about how to interface Arduino and motor with PC. They have also
studied how to control the speed of a DC motors in a real-time world. To accomplish the experiment
markable safety measures have been taken care.