0% found this document useful (0 votes)
58 views

Working Explanation

The document provides code to program a Raspberry Pi to blink an LED. It instructs the user to open Python 3 on the Raspberry Pi desktop, create a new file called "blinky", and paste in code that imports GPIO and time libraries, sets up pin 40 as an output, turns the pin on and off with 1 second delays, and repeats this process three times to make the LED blink on and off.

Uploaded by

ainurasyar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

Working Explanation

The document provides code to program a Raspberry Pi to blink an LED. It instructs the user to open Python 3 on the Raspberry Pi desktop, create a new file called "blinky", and paste in code that imports GPIO and time libraries, sets up pin 40 as an output, turns the pin on and off with 1 second delays, and repeats this process three times to make the LED blink on and off.

Uploaded by

ainurasyar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

5.

After that write the program for blinky as


Working Explanation: given below and execute the program by
clicking on “RUN” on ‘DEBUG’ option.
Since we have everything ready, turn ON
your PI and go to the desktop.
1. On the desktop, go the Start Menu and
choose for the PYTHON 3, as shown in
figure below.

Code:
import RPi.GPIO as IO # calling header file
for GPIO’s of PI
import time # calling for time to
provide delays in program
IO.setmode (IO.BOARD) # programming the
2. After that, PYHON will run and you will GPIO by BOARD pin numbers, GPIO21 is called as
see a window as shown in below figure. PIN40
IO.setup(40,IO.OUT) # initialize digital pin40
as an output.
IO.output(40,1) # turn the LED on
(making the voltage level HIGH)
time.sleep(1) # sleep for a second
IO.cleanup() # turn the LED off
(making all the output pins LOW)
time.sleep(1) #sleep for a second
#loop is executed second time
IO.setmode (IO.BOARD)
IO.setup(40,IO.OUT)
IO.output(40,1)
time.sleep(1)
3. After that, click on New File in File Menu, IO.cleanup()
You will see a new Window open, time.sleep(1)
#loop is executed third time
IO.setmode (IO.BOARD)
IO.setup(40,IO.OUT)
IO.output(40,1)
time.sleep(1)
IO.cleanup()
time.sleep(1)

4. Save this file as blinky on the desktop,

You might also like