0% found this document useful (0 votes)
219 views7 pages

ROBOTICS Lab Manual

The document describes 4 experiments: 1. Using LEDs and APIs to detect the vertical movement of a drone and print velocity values 2. Using a servo motor to rotate from 0 to 180 degrees and plot the angle values 3. Connecting a NEMA stepper motor to an Arduino using an L293D motor driver and stepping through revolutions in both directions 4. Learning about stepper motors with an Arduino IDE, L293D motor driver, and NEMA stepper motor

Uploaded by

paridhi kaushik
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)
219 views7 pages

ROBOTICS Lab Manual

The document describes 4 experiments: 1. Using LEDs and APIs to detect the vertical movement of a drone and print velocity values 2. Using a servo motor to rotate from 0 to 180 degrees and plot the angle values 3. Connecting a NEMA stepper motor to an Arduino using an L293D motor driver and stepping through revolutions in both directions 4. Learning about stepper motors with an Arduino IDE, L293D motor driver, and NEMA stepper motor

Uploaded by

paridhi kaushik
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/ 7

Experiment-2

Objective: Debug different APIs in Pluto

Problem Statement: To detect the movement of PlutoX in vertical direction (upwards


and downwards) byusing LEDs on board and printing the velocity values on the Pluto
Monitor.

Requirement Tool & Software: Cygnus IDE, Pluto Drone

Code: The Code for the following task is here


// Do not remove the include below
#include"PlutoPilot.h"
#include"Estimate.h"
#include"Utils.h"

//The setup function is called once at PlutoX's hardware startup


voidplutoInit()
{
//Add your hardware initialization code here

//The function is called once before plutoLoop() when you activate developer mode
voidonLoopStart()
{
//Do your one time stuff here
LED.flightStatus(DEACTIVATE);

//The loop function is called in an endless loop


voidplutoLoop()
{
//Add your repeated code here
if(Velocity.get(Z) > 0) /*If the drone is moving upwards (Velocity in the
Z axis will be positive)*/
{
LED.set(RED, ON);
LED.set(GREEN, OFF);
}
else/*If the drone is moving downwards*/
{
LED.set(RED, OFF);
LED.set(GREEN, ON);
}
Monitor.println("Velocity Z: ", Velocity.get(Z));
Graph.red(Velocity.get(Z), 1);
}

//The function is called once after plutoLoop() when you deactivate developer mode
voidonLoopFinish()
{
//Do your cleanup stuff here
LED.flightStatus(ACTIVATE);

Result:
Experiment-3
Objecive: Learn about the Servo Motor

Require Tools & software: Arduino IDE, ServoMotor

Description: In This experiment we use the servo Motor from 0° to 180° angle and plot the
angle value on ArduinoIDE Serial Plotter.

Code:
#include <Servo.h>

Servo myservo; // create servo object to control a servo

// twelve servo objects can be created on most boards

int pos = 0; // variable to store the servo position

void setup() {

myservo.attach(9); // attaches the servo on pin 9 to the servo object

void loop() {

for (pos = 0; pos<= 180; pos += 1) { // goes from 0 degrees to 180 degrees

// in steps of 1 degree

myservo.write(pos); // tell servo to go to position in variable 'pos'

Serial.println(pos);

delay(15); // waits 15ms for the servo to reach the position

for (pos = 180; pos>= 0; pos -= 1) { // goes from 180 degrees to 0 degrees

myservo.write(pos); // tell servo to go to position in variable 'pos'


Serial.println(pos);

delay(15); // waits 15ms for the servo to reach the position

Result:
Experiment-4
Objective: Learn StepperMotor with L293D Motor Driver & Arduino

Requirement Tool & Software: NEMA Stepper Motor, Arduino IDE, L293D
MotorDriver

Description: we are using NEMA 17 bipolar stepper rated at 12V. It offers 200 steps per
revolution, and can operate at 60 RPM.

Connection: The connections are fairly simple. Start by connecting external 12V power
supply to the Vcc2 pin and 5V output on Arduino to the Vcc1 pin. Make sure you common
all the grounds in the circuit.

You also need to connect both the ENA & ENB pins to 5V output so the the motor is always
enabled.

Now, connect the input pins(IN1, IN2, IN3 and IN4) of the L293D IC to four digital output
pins(12, 11, 10 and 9) on Arduino.

Finally, connect the A+ (Red), A- (Green), B+ (Blue) and B- (Yellow) wires from the stepper
motor to the L293D’s output pins (Out4, Out3, Out2 & Out1) as shown in the illustration
below.
12 Volt Adapter

Arduino Code:

// Include the Arduino Stepper Library


#include <Stepper.h>

// Number of steps per output rotation


constintstepsPerRevolution = 200;

// Create Instance of Stepper library


Stepper myStepper(stepsPerRevolution, 12, 11, 10, 9);

voidsetup()
{
// set the speed at 20 rpm:
myStepper.setSpeed(20);
// initialize the serial port:
Serial.begin(9600);
}

voidloop()
{
// step one revolution in one direction:
Serial.println("clockwise");
myStepper.step(stepsPerRevolution);
delay(500);

// step one revolution in the other direction:


Serial.println("counterclockwise");
myStepper.step(-stepsPerRevolution);
delay(500);
}

Result: The plot of Stepper Motor is following:

You might also like