Experimet 4 (IOT)

You might also like

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

Experiment 4

(A) LED bilking using Raspberry pi on Proteus using flowchart.

Components: Raspberry pi, LED, Button

Simulator: Proteus 8 Professional

Explanation:

In order to blink an LED,


We pass HIGH to turn it on
When the push button is switched on
We pass LOW to turn it off
When the push button is switched off

Perform the above instructions in a loop.

Circuit:

23
Flowchart:

Output:

24
(b) LED bilking without push button using Raspberry pi on Proteus using flowchart.

Components: Raspberry pi, LED, Button

Simulator: Proteus 8 Professional

Explanation:

In order to blink an LED,


We pass HIGH to turn it on
Give some delay
We pass LOW to turn it off
Give some delay

Perform the above instructions in a loop.

Circuit:

25
Flowchart:

(c) Flash an LED at a given on time and off time cycle, where the two times are taken
from a file.

Python Program:

To start, you need to make sure that your Raspberry Pi is connected to the internet. This is
needed to track time. Then type in this code:

import RPi.GPIO as GPIO


import datetime
import time

pin = your_output_pin_here
GPIO.setup(pin, GPIO.OUT)

while True:
time = datetime.datetime.now().strftime("%H:%M")
26
if time == "12:00":
GPIO.output(pin, True)
time.sleep(number_of_seconds_for_led_to_be_on_here)
GPIO.output(pin, False)
time.sleep(0.030)

Replace things like 12:00 and your_output_pin_here with your own values. Every 30
milliseconds, it checks whether it is 12:00. If it is, it turns on the LED. It then waits a number of
seconds, then turns it back off.

27

You might also like