0% found this document useful (0 votes)
24 views3 pages

Iot 7 Shivaji

iot worksheet

Uploaded by

aditya.cse107
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)
24 views3 pages

Iot 7 Shivaji

iot worksheet

Uploaded by

aditya.cse107
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/ 3

DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING

Experiment 7

Student Name: Shivaji UID:22bcs15077


Branch: CSE Section/Group: 636-B
Semester: 5 Date of Performance:
17/07/2024
Subject Name: IOT LAB Subject Code: 22CSP-329

1. Aim:
To Assemble and Controlling of actuators using Arduino Uno.

Objective:
The objective of this task is to understand and implement basic actuator components
such as servo motors, LEDs, using an Arduino microcontroller. This experiment
involves connecting these components correctly and observing their behavior,
controlled via potentiometer input (Knob Circuit) and Pulse Width Modulation (PWM)
signals. The aim is to gain practical experience in controlling actuators through
electrical connections .

Input/Equipment Used-
• 1x Arduino
• 1x servo motor
• 1x jumper wires
• 1x push button
Procedure-
1. Connect the servo's signal wire to pin 9, power to 5V, and ground to GND on the
Arduino.
2. Attach the push button between pin 2 and GND.
3. In the code, initialize the servo on pin 9 and set pin 2 as input.
4. Press the button to move the servo from 0 to 180 degrees.
5. Release the button to return the servo to 0 degrees.
6. Upload the code to the Arduino and observe the servo's movement.
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

Connections:

→Servo Motor:
Red wire (Power) → 5V on Arduino
Black/Brown wire (Ground) → GND on Arduino
Yellow/Orange wire (Signal) → Pin 9 on Arduino

→Push Button:
One terminal → Pin 2 on Arduino
Other terminal → GND on Arduino

CODE

#include <Servo.h>
Servo servo; int
currentAngle = 1;
bool buttonPressed = false;

void setup() {
servo.attach(9);
pinMode(2, INPUT_PULLUP); servo.write(currentAngle);
}

void loop() {
if (digitalRead(2) == LOW && !buttonPressed) {
buttonPressed = true;
while (digitalRead(2) == LOW && currentAngle < 180) {
servo.write(++currentAngle);
delay(5);
}
}

if (digitalRead(2) == HIGH && buttonPressed) {


buttonPressed = false;
while (currentAngle > 0) {
servo.write(--currentAngle);
delay(5);
}
}
}
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

Result

Learning Outcomes
 Learn to control a servo motor's position with PWM signals.
 Understand handling button inputs in Arduino programming.
 Implement incremental movement for precise actuator control.
 Develop basic Arduino programming skills for simple control tasks.

You might also like