Introduction_to_Digital_Devices_with_PI

SRJRPYS003

Raspberry Pi session 3

INTRODUCTION TO DIGITAL DEVICES WITH PI

There are two types of electronics devices

  1. Digital
  2. Analogue

Digital Devices: The devices which works on digital signals. Digital signal are discrete signal and doesn’t vary with respect to time for example-

Electric switch: It has two discrete signal On and Off

Analogue Devices: The devices which works on the analogue signals. Analogue signals vary continuously with respect to time. For example-

LED bulb: Its intensity is vary continuously with time

Application of Digital Devices:

  1. Digital Radio
  2. Television
  3. Music and Audio Player
  4. CPU in PC
  5. Home devices

Activity: Security Alarm

To save important objects we can make the security alarm so if anyone want to take your things then alarm will be ring.

Component required: Raspberry pi 3 board , IR sensor , Buzzer , Green LED , Red LED , Jumper wires

Coding:

import RPi.GPIO as GPIO

import time

sensor = 16

buzzer = 40

green = 13

red = 22

GPIO.setmode(GPIO.BOARD)

GPIO.setup(sensor,GPIO.IN)

GPIO.setup(buzzer,GPIO.OUT)

GPIO.setup(green, GPIO.OUT)

GPIO.setup(red, GPIO.OUT)

GPIO.output(buzzer,False)

GPIO.output(red, False)

print ("IR Sensor Ready.....")

print (" ")

GPIO.output(green, True)

try:

while True:

if GPIO.input(sensor):

GPIO.output(buzzer,True)

GPIO.output(red, True)

GPIO.output(green, False)

print ("Object Detected")

while GPIO.input(sensor):

time.sleep(1)

else:

GPIO.output(buzzer,False)

GPIO.output(green, True)

GPIO.output(red, False)

print ("Path is clear")

except KeyboardInterrupt: GPIO.cleanup()

Connect a touch sensor and buzzer with PI and make a activity that when you press the touch sensor then buzzer will ring