0% found this document useful (0 votes)
18 views2 pages

Practical No 10 IOT

The document outlines a practical project to create an IoT application using an Arduino board to control a servo motor's movement across 180 degrees. It includes a list of required components, a circuit diagram, and the Arduino code necessary for operation. The code demonstrates how to move the servo back and forth while providing serial output of its position.

Uploaded by

pinali patel
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)
18 views2 pages

Practical No 10 IOT

The document outlines a practical project to create an IoT application using an Arduino board to control a servo motor's movement across 180 degrees. It includes a list of required components, a circuit diagram, and the Arduino code necessary for operation. The code demonstrates how to move the servo back and forth while providing serial output of its position.

Uploaded by

pinali patel
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/ 2

Practical 10

Aim:- Develop an IoT based application using Arduino board to control servo
motors back and forth across 180 degrees.

Circuit diagram:-

Component:-
1. Arduino Board (e.g., Arduino Uno)
2. Servo Motor
3. Jumper Wires
4. Power Supply (for servo)
5. Breadboard
Code:-
#include <Servo.h> // Include the Servo library

// Define servo object


Servo myServo;

// Define servo pin


const int servoPin = 9;
void setup() {
Serial.begin(9600); // Initialize serial communication
myServo.attach(servoPin); // Attach servo to pin
}

void loop() {
// Move servo from 0 to 180 degrees
for (int pos = 0; pos <= 180; pos++) {
myServo.write(pos);
Serial.print("Servo Position: ");
Serial.println(pos);
delay(1); // Small delay for smooth movement
}

// Move servo from 180 to 0 degrees


for (int pos = 180; pos >= 0; pos--) {
myServo.write(pos);
Serial.print("Servo Position: ");
Serial.println(pos);
delay(1);
}
}

You might also like