Computer networks unit III CHAPTER of frameworks

manforlover7 10 views 45 slides Mar 11, 2025
Slide 1
Slide 1 of 45
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45

About This Presentation

It is about the system networks


Slide Content

I2C LCD Display

Pin Description of I2C Module The term I2C stands for  “ Inter Integrated Circuits ” . It is normally denoted as  IIC or I squared C  or even as 2-wire interface protocol (TWI). I2C is a synchronous communication protocol , means both the devices that are sharing the information must share a common clock signal. It has only two wires, SDA (serial data) and SCL to share information, out of which  SCL (serial clock )  is used for the clock signal and  SDA  is used for sending and receiving data.

It is very useful IC and can be used in LED signs boards, displays, Key pads, Industrial control, etc. There are 8 I/O pins, 3 pins (A0, A1, A2) for I2C bus address and SDA, SCL pins.

Hardware Required

Interfacing Diagram

#include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd (0x20, 16, 2); // Format -> ( Address,Width,Height )   void setup ( ) {    lcd.init ( ); // initialize the lcd   lcd.backlight (); // Turn on the Backlight }

void loop ( ) {   lcd.clear ( ); // Clear the display buffer   lcd.setCursor (0, 0); // Set cursor (Column, Row)   lcd.print ("Hello"); // print "Hello" at (0, 0)      lcd.setCursor (0,1 ); // Set cursor (Column, Row)   lcd.print ("Geek"); // print "Geek" at (0, 1)   delay(100 ); }

Buzzer with Arduino By interfacing a buzzer with Arduino , you can create sound effects, alarms, melodies, and more. Buzzers can be found in alarm devices, computers, timers and confirmation of user input such as a mouse click or keystroke . converting electronic vibrations into speaker pulses which vibrate the air . Ex : Arduino to play “ Twinkle Twinkle Little Star”

For this tutorial you will need: Arduino uno Breadboard Buzzer/piezo speaker 100 Ohm resistor

const int buzzer = 9; //buzzer to arduino pin 9 void setup () { pinMode (buzzer , OUTPUT); // Set buzzer - pin 9 as an output } void loop () { tone(buzzer , 1000); // Send 1KHz sound signal... delay(1000); // ...for 1 sec noTone (buzzer); // Stop sound... delay(1000 ); // ...for 1sec }

Using Sensors and Actuators with Arduino Sensors : Sensor is a device used for the conversion of physical events or characteristics into the electrical signals.  capturing data from the physical world. This is a hardware device that takes the input from environment and gives to the system by converting it.

Types of Sensors Accelerometer Light sensor Sound sensor Pressure sensor Temperature sensor IR sensor Ultrasonic sensor humidity sensor PIR sensor Water detector sensor Light distance sensor

Actuator: Actuator is a device that converts the electrical signals into the physical events or characteristics . It takes the input from the system and gives output to the environment. Ex:  motors and heaters  

Interfacing IR Sensor Module with Arduino An  infrared proximity sensor or IR Sensor  is an electronic device that emits infrared lights to sense some aspect of the surroundings and can be employed to detect the motion of an object . This sensor is very common in the electronic industry and if you’ve ever tried to design an obstacle avoidance robot or any other proximity detection-based system.

The IR sensor has a 3-pin connector that interfaces it to the outside world.

The  working of the IR sensor module  is very simple, it consists of two main components: the first is the IR transmitter section and the second is the IR receiver section . In the transmitter section,  IR led  is used and in the receiver section, a  photodiode  is used to receive infrared signal and after some signal processing and conditioning, you will get the output.

i nt IRSensor = 9; // connect IR sensor module to Arduino pin D9 int LED = 13; // connect LED to Arduino pin 13 void setup( ) { Serial.begin (115200); // Init Serial at 115200 Baud Rate. Serial.println ("Serial Working"); // Test to check if serial is working or not pinMode ( IRSensor , INPUT); // IR Sensor pin INPUT pinMode (LED, OUTPUT); // LED Pin Output }

void loop ( ) { int sensorStatus = digitalRead ( IRSensor ); // Set the GPIO as Input if ( sensorStatus == 1) // Check if the pin high or not { // if the pin is high turn off the onboard Led digitalWrite (LED , LOW); // LED LOW Serial.println ("Motion Detected!"); // print Motion Detected! on the serial monitor window } else { // else turn on the onboard LED digitalWrite (LED , HIGH); // LED High Serial.println ("Motion Ended!"); // print Motion Ended! on the serial monitor window } }

H umidity sensor with Arduino Humidity:   Humidity  is the amount of water in the surrounding air. Humidity Sensor (DHT22) The DHT-22 (also named as AM2302) is a digital-output. Humidity is the water vapor around you mixed with air. It is measured in per cents.

#include < dht22.h > #define DHT22PIN 4 dht22 DHT22 ; void setup() { Serial.begin (9600 ); } void loop() { Serial.println (); int chk = DHT22.read(DHT11PIN); Serial.print ("Humidity (%): "); Serial.println ((float)DHT22.humidity, 2); Serial.print ("Temperature (C): "); Serial.println ((float)DHT22.temperature, 2); delay(2000); }

Water Level Sensor Interface with Arduino Water Level Sensor measure the water level( detect the presence of water .) The Water Level Sensor has ten exposed copper traces . five of which are power traces and the remaining five are sense traces . These traces are interlaced so that there is one sense trace between every two power traces .

Normally, power and sense traces are not connected, but when immersed in water, they are bridged.

#define sensorPower 7 # define sensorPin A0 // Value for storing water level int val = 0; void setup () { // Set D7 as an OUTPUT pinMode ( sensorPower , OUTPUT); // Set to LOW so no power flows through the sensor digitalWrite ( sensorPower , LOW); Serial.begin (9600); }

void loop() { //get the reading from the function below and print it Int level = readSensor (); Serial.print ("Water level: "); Serial.println (level ); delay(1000 ); } // This is a function used to get the reading int readSensor () { digitalWrite ( sensorPower , HIGH); // Turn the sensor ON delay(10 ); // wait 10 milliseconds val = analogRead ( sensorPin ); // Read the analog value form sensor digitalWrite ( sensorPower , LOW); // Turn the sensor OFF return val ; // send current reading }

Ultrasonic sensor with Arduino Sensors are widely used for detecting devices by approximating their distance from the source . example of a sensor is the HC-SR04 ultrasonic sensor which uses the SONAR technique for the sensing purpose. The main feature of this sensor is to mimic the nature of bats and therefore predict the distance of objects without actually establishing contact with the device.

Working of the Ultrasonic Sensor The Ultrasonic Sensor works on the principle of reflection . The sensor is used to emit waves known as ultrasound with a frequency of 40 KHz. The transmitted wave moves in a straight line path and gets obstructed by an object if present. After being obstructed, the wave reflects and is detected by the  sensor . The time of transmission and reflection of the wave is noticed and the distance of the object is calculated using the speed-time formula . s= 2d/t

Connect a wire to supply V cc  with 5V to the appropriate pin on Arduino . Make a ground-to-ground connection from GND to GND on Arduino . Connect the trigger i.e. Trig to any pin on Arduino like pin 8. Connect the Echo to any pin on Arduino like pin 9.

const int trigPin = 9 ; const int echoPin = 10 ; float duration, distance; void setup() { pinMode ( trigPin,OUTPUT ); pinMode ( echoPin , INPUT); Serial.begin (9600 ); } void loop() { digitalWrite ( trigPin , LOW); delayMicroseconds (2); digitalWrite ( trigPin , HIGH); delayMicroseconds (10); digitalWrite ( trigPin , LOW); duration = pulseIn ( echoPin , HIGH); distance =(duration*.0343)/2; Serial.print ("Distance: "); Serial.println (distance); delay(100); }

const int pingPin = 8; const int echoPin = 9; void setup() { Serial.begin (9600); } void loop() { long duration, inches, cm; pinMode ( pingPin , OUTPUT); digitalWrite ( pingPin , LOW); delayMicroseconds (2 ); digitalWrite ( pingPin , HIGH); delayMicroseconds (10 ); digitalWrite ( pingPin , LOW); pinMode ( echoPin , INPUT); duration = pulseIn ( echoPin , HIGH); inches = microsecondsToInches (duration); cm = microsecondsToCentimeters (duration); Serial.print (inches); Serial.print ("in, "); Serial.print (cm); Serial.print ("cm"); Serial.println (); delay(100); } long microsecondsToInches (long microseconds) { return microseconds / 74 / 2; } long microsecondsToCentimeters (long microseconds) { return microseconds / 29 / 2; }

Accelerometer Interface with Arduino Accelerometers is the device capable of detecting changes in motion in the form of acceleration. It can also measure the vibration of the structure. Accelerometers are widely used in low-power, low-cost motion and tilt sensing applications such as mobile devices, gaming systems, disk drive protection, image stabilization, and sports and health devices . Ex:  ADXL320, ADXL321, ADXL322, ADXL330 It can measure not only static acceleration caused by gravity, but also dynamic acceleration caused by motion, shock, or vibration.

Connect the VCC pin to the Arduino’s 5V pin and the GND pin to the Arduino’s Ground pin. Connect the X, Y, and Z outputs to Arduino’s analog pins A0, A1, and A2 . To get accurate results, we need to change the analog reference (AREF) voltage on the Arduino . This is accomplished by connecting the Arduino’s 3.3V pin to the AREF pin.

const int groundpin = 18; // analog input pin 4 -- ground const int powerpin = 19; // analog input pin 5 -- voltage const int xpin = A3; // x-axis of the accelerometer const int ypin = A2; // y-axis const int zpin = A1; // z-axis (only on 3-axis models) void setup () { Serial.begin (9600 ); pinMode ( groundpin , OUTPUT ); pinMode ( powerpin , OUTPUT ); digitalWrite ( groundpin , LOW ); digitalWrite ( powerpin , HIGH); }

void loop() { // print the sensor values: Serial.print ( analogRead ( xpin )); // print a tab between values: Serial.print ("\t "); Serial.print ( analogRead ( ypin )); // print a tab between values: Serial.print ("\t"); Serial.print ( analogRead ( zpin )); Serial.println (); // delay before next reading: delay(100 ); }

Arduino - PIR Sensor PIR sensors allow you to sense motion. They are used to detect whether a human has moved in or out of the sensor’s range . They are commonly found in appliances and gadgets used at home or for businesses . They are often referred to as PIR, "Passive Infrared", " Pyroelectric ", or "IR motion" sensors . PIRs are made of pyroelectric sensors, a round metal can with a rectangular crystal in the center, which can detect levels of infrared radiation.

#define pirPin 2; int calibrationTime = 30; long unsigned int lowIn ; long unsigned int pause = 5000 ; boolean lockLow = true ; boolean takeLowTime ; int PIRValue = 0; void setup () { Serial.begin (9600); pinMode ( pirPin , INPUT); }

void PIRSensor () { if( digitalRead ( pirPin ) == HIGH) { if( lockLow ) { PIRValue = 1 ; lockLow = false; Serial.println ("Motion detected."); delay(50); } takeLowTime = true; } if( digitalRead ( pirPin ) == LOW) { if( takeLowTime ) { lowIn = millis (); takeLowTime = false; } if(! lockLow && millis () - lowIn > pause) { PIRValue = 0 ; lockLow = true; Serial.println ("Motion ended."); delay(50 ); } } }
Tags