Iot 7 Shivaji
Iot 7 Shivaji
Experiment 7
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);
}
}
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.