Iot 7

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING

Experiment-7
Student Name: Yashas Bhardwaj UID: 22BCS15817
Branch: CSE Section/Group: IOT_622-A
Semester: 5 Date of Performance: 4-10-24
Subject Name: IOT ARCHITECTURE AND ITS PROTOCOLS
Subject Code: 22CSP-329

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

2. Objective:
1. Learn about IoT based simulations.
2. Testing and model in IoT based simulation platform.

3. Software/Hardware Required:
1. 1x Arduino
2. 1x LED
3. 1x Motor
4. 1x Buzzer

4. Script:
Actuators

Servo Motors: Servomotors have three wires: power, ground, and signal. The power wire is
typically red, and should be connected to the 5V pin on the Arduino board. The ground wire
is typically black or brown and should be connected to a ground pin on the board. The signal
pin is typically yellow or orange and should be connected to PWM pin on the board. In these
examples, it is pin number 9.

Knob Circuit
For the Knob example, wire the potentiometer so that its two outer pins are connected to
power (+5V) and ground, and its middle pin is connected to Ao on the board. Then, connect
the servomotor to +5V, GND and pin 9.
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

LED: LEDs (light-emitting diodes) are small, bright, power-efficient lights commonly used
in electronic products.
An LED light is a polarized part, meaning it has to be connected to a circuit in a certain way
to work properly. Specifically, each LED has a positive leg and a negative leg. These can be
identified visually by length: the negative leg has been made shorter.

Buzzer: The buzzer is a sounding device that can convert audio signals into sound signals. It
is usually powered by DC voltage. It is widely used in alarms, computers, printers and other
electronic products as sound devices. It is mainly divided into piezoelectric buzzer and
electromagnetic buzzer, represented by the letter "H" or "HA" in the circuit. According to
different designs and uses, the buzzer can emit various sounds such as music, siren, buzzer,
alarm, and electric bell.
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

Code:

// Pin definitions
const int ledPin1 = 2; // Connect first LED to digital pin 2
const int ledPin2 = 3; // Connect second LED to digital pin 3
const int motorPin = 4; // Connect motor to digital pin 4
void setup() {
pinMode(ledPin1, OUTPUT); // Set LED pin as output
pinMode(ledPin2, OUTPUT); // Set LED pin as output
pinMode(motorPin, OUTPUT); // Set motor pin as output
}
void loop() {
// Turn on LED 1 and motor
digitalWrite(ledPin1, HIGH);
digitalWrite(motorPin, HIGH);
delay(1000); // Wait for 1 second
// Turn off LED 1 and motor
digitalWrite(ledPin1, LOW);
digitalWrite(motorPin, LOW);
delay(1000); // Wait for 1 second
// Turn on LED 2
digitalWrite(ledPin2, HIGH);
delay(1000); // Wait for 1 second
// Turn off LED 2
digitalWrite(ledPin2, LOW);
delay(1000); // Wait for 1 second
}
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

Connections:

5. Learning Outcomes:
• Understand pin configurations, I/O modes, and how to program the Arduino Uno using the
Arduino IDE.
• Learn how to control a servo motor using the Arduino, including setting positions with PWM
signals.
• Practice basic LED and motor control in Arduino, alternating between different components.
• Explore simple logic for controlling multiple outputs in a loop structure.

You might also like