#14 Begin with Raspberry Pi 3: Blink LED (Python Program) | APDaga Tech

#14 Begin with Raspberry Pi 3: Blink LED (Python Program) | APDaga Tech

IoT Tutorial #14 [ Raspberry Pi Tutorials #2 ]

In the last post, we have seen how to install Raspbian OS on new Raspberry Pi and boot it for the first time.

It assumed that you have already connected to the Raspberry pi3 using either SSH or VNC at this point.


If not, Follow these steps to boot the Raspberry Pi for the first time with Raspbian OS: 
Raspberry Pi 3: Configure and Boot RPi3 for the first time and Connect using SSH and VNC (using Command line)


Here, I will show you a simple python program to test your GPIO Pins of Raspberry Pi 3 (Model B)

Description:
In this program, LED is connected to GPIO of RPi3 board and the LED will blink for 20 times with a delay of 1 sec.

Requirements:
- Raspberry Pi 3 (with Raspbian Stretch OS in it)
- 5V 2A Adapter / Mobile charger
- Micro USB cable
- 1 LED
- 1k Resistor
- Bread Board
- Female to Male wires (minimum 2)

Physical Connections:

RPi3              ->  LED_Pins
Board Pin 7 -> LED+
Board Pin 6 (Gnd) -> LED-



Pin Layout: (Raspberry Pi 3 - Model B)
Raspberry Pi 3 (Model B): Board layout (inner) in Circles and BCM layout (outer)

Downloads:
Download link is given in the Description of the YouTube video shown below.

Demonstration:







Program: (python)
import RPi.GPIO as GPIO             # Import GPIO Library
import time # Import 'time' library for delay / sleep

led_pin = 7 # Connect LED + to Pin 7

GPIO.setmode(GPIO.BOARD) # Use Board Pin Numbering
#GPIO.setmode(GPIO.BCM) # Use BCM Pin Numbering

GPIO.setup(led_pin,GPIO.OUT) # Set Pin 7 as Output

for i in range(0,20): # To Blink LED 20 times
GPIO.output(led_pin,GPIO.HIGH) # LED ON
time.sleep(1) # wait for 1sec
GPIO.output(led_pin,GPIO.LOW) # LED OFF
time.sleep(1) # wait for 1sec

GPIO.cleanup() # To clean up all the ports you’ve used

Click here to see more codes for Raspberry Pi 3 and similar Family.
&
Click here to see more codes for NodeMCU ESP8266 and similar Family.
&
Click here to see more codes for Arduino Mega (ATMega 2560) and similar Family.

Feel free to ask doubts in the comment section. I will try my best to solve it.
If you find this helpful by any mean like, comment and share the post.
This is the simplest way to encourage me to keep doing such work.

Thanks and Regards,
-Akshay P. Daga
Post a Comment (0)
Previous Post Next Post