Raspberry Pi - 2 Simple LED Blinking program using Python
For Flashing/Blinking the Led on breadboard using python follow bellow steps.
· Required List of components :
a). 1 - Raspberry Pi device with 5 V power supply.
b). 1 - Bread Board
c). 1 - Male to Female jumper cable
d). 1 - LED
1. First connect the GPIO pin to the bread board as shown in figure.
2. Here we use the PIN Number: “ 4 “ (As per number 4(pin rank 7) , third from the top – left ). for get the output from the raspberry pi so connect eh jumper wire from Raspberry PI GPIO pin “4” to bread board as shown in image
3. Now take LED and put it on bread board as show in image.
Connect the Plus terminal of LED to the Jumper cable (green cable in image) come from the GPIO Pin “4” as shown in image
Now take another jumper cable (black cable in image) connect it the GPIO pin “Ground” (As per number 3(Pin rank 6) , third from the top – right ). And other terminal of this wire to minus terminal of the LED as shown in figure.
Here for detecting the plus/minus terminal of LED, bigger (toll) terminal of LED is Plus and Small (short) terminal of LED is minus. Or you can define it by cutting side part of LED is Minus terminal.
6. Now write the python program for blink LED every 1 second.
------------------------------------------------------------------------------------
import RPi.GPIO as GPIO
import time
#assign numbering for the GPIO using BCM
GPIO.setmode(GPIO.BCM)
#assingn number for the GPIO using Board
#GPIO.setmode(GPIO.BOARD)
cnt = 0
MAIL_CHECK_FREQ = 1 # change LED status every 1 seconds
RED_LED = 4
GPIO.setup(RED_LED, GPIO.OUT)
while True:
if cnt == 0 :
GPIO.output(RED_LED, False)
cnt = 1
else:
GPIO.output(RED_LED, True)
cnt = 0
time.sleep(MAIL_CHECK_FREQ)
GPIO.cleanup()
7. Now Run the Program Show the Output as shown below.
Now you enjoy with your raspberry PI, if you like my tutorial then comment on this. And if you have any query the write it to comment box or mail me on n005nirav@gmail.com
- What is Class and Object in C#.net ?
- What is Encapsulation in C#.Net ?
- What is Abstract Class in C#.Net,How to use Abstract class in .net?
- Wht is Inheritance in c#.net ?
- What is Method Overloading in .Net?
Comments
Post a Comment