Summer training at Goeduhub Technologies-Jaipur
Register for Free Certified Workshop on AI & Machine Learning:: 23-02-2020 ||  Career options for aspiring CS/ITECEEE or EIC or EEE Engineers
0 like 0 dislike

1 Answer

0 like 0 dislike
by (6.7k points)
selected by
Best answer

Hardware requirement and connections:

Hardware requirement and connections are same as explained in 

Turning on and off LED with your Raspberry Pi's GPIO Pins

LED to Raspberry-PI_IOT-Training-in-Jaipur

Python program

import RPi.GPIO as GPIO # Importing RPi library to use the GPIO pins

from time import sleep # Importing sleep from time library

led_pin = 21 # Initializing the GPIO pin 21 for LED

GPIO.setmode(GPIO.BCM) # We are using the BCM pin numbering

GPIO.setup(led_pin, GPIO.OUT) # Declaring pin 21 as output pin

pwm = GPIO.PWM(led_pin, 100) # Created a PWM object

pwm.start(0) # Started PWM with 0% duty cycle

while 1: # Loop will run forever

          for x in range(100): # This Loop will run 100 times

                    pwm.ChangeDutyCycle(x) # Change duty cycle

                    sleep(0.01) # Delay of 10mS

          for x in range(100,0,-1): # Loop will run 100 times; 100 to 0



pwm.stop() # Stop the PWM

GPIO.cleanup() # Make all the output pins LOW

 Go to your Branch CSE or IT | ECE | EE, EIC or EEEMECE
 Know About Popular Colleges/Universities  List of IITsList of NITs | RTU-KOTA | Manipal University-Jaipur | JECRC University | Amity University Jaipur | BIT Mesra-Jaipur | MODY UNIVERSITY | LNMIIT-Jaipur | JK Lakshmipat | Banasthali Vidyapith | POORNIMA University
 Exams:   List of Exams After Graduation | List of Engineering Entrance Examinations (UG/PG) | JEE Main | JEE Advanced | GATE | IES | ISROList of PSUs
Placements:  List of companies | Logical Reasoning Questions | Quantitative Aptitude Questions | General English Questions | Technical-MCQ and Interview Questions
 Download Previous Year Papers For:  GATE | IES | RAJASTHAN TECHNICAL UNIVERSITY (RTU-Kota)RPSC Technical Exams | ISRO
 Online Free Training:  Artificial Intelligence(AI) Machine Learning(ML)Python Programming | Internet of Things-IoT | OpenCV (Open Source Computer Vision Library) | LINUX | Big Data : Hadoop | 
About Us | Contact Us   Social::   |  |