You can read my previous article:
Here are the steps for flashing/blinking the LED on breadboard using python.
Download Source code: LedBlinker_Python.rar
Required List of components
- 1 - Raspberry Pi device with 5 V power supply.
- 1 - Bread Board
- 1 - Male to Female jumper cable
- 1 - LED
1. Firstly, connect the GPIO pin to the bread board as shown in figure.
Figure 1: Connect the GPIO pin to the bread board
2. Here we use the PIN Number: “ 4 “ (As per number 4(pin rank 7) , third from the top – left ). For getting the output from the Raspberry PI connect eh jumper wire from Raspberry PI GPIO pin “4” to bread board as shown in image.
Figure 2: Connect eh jumper wire from Raspberry PI GPIO pin
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) coming from the GPIO Pin “4” as shown in image.
Figure 3: Connect the Plus terminal of LED to the Jumper cable
4. 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.
Figure 4: Black cable in image
5. Here for detecting the plus/minus terminal of LED, bigger (toll) terminal of LED is plus and smaller (short) terminal of LED is minus. Or you can define it by cutting, the side part of LED is Minus terminal.
Figure 5: Detecting the plus-minus terminal of LED
6. Now write the python program for blinking LED every 1 second.
- ------------------
- import RPi.GPIO as GPIO
- import time
-
- GPIO.setmode(GPIO.BCM)
-
-
-
- cnt = 0
- MAIL_CHECK_FREQ = 1
- RED_LED = 4
- GPIO.setup(RED_LED, GPIO.OUT)
- while True:
- ifcnt == 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 and you can see the following output:
Figure 6: Program Show the Output
Download Source code:
LedBlinker_Python.rar
Now you enjoy with your Raspberry PI and if you like my tutorial or have any query comment on this.