loading

Hi ! I am going to show you how to dim a LED with Raspberry Pi.

Difficulty : EASY/BEGINNER.

Stay tuned for the next instructables!

Step 1: What Do We Need?

Hi ! I am going to show you how to dim a LED with Raspberry Pi.

Difficulty : EASY/BEGINNER.

First. You will need :

  • Raspberry Pi
  • 2 pcs Male/Female Connectors
  • 1 pcs of a minimum of 100 OmH resistor.
  • 1 pcs LED
  • 1 pcs breadboard.

Step 2: Connect All Parts Together and Let's Have FUN.

Step 3: Write the Python Code.

To connect the LED with the Raspberry PI and to make it dim we need to write the software code.For this I used Python language.

import RPi.GPIO as GPIO

import time

GPIO.setwarnings(False)

GPIO.setmode(GPIO.BOARD)

GPIO.setup(7,GPIO.OUT)

def dim()

	red_led = GPIO.PWM(7,100)

	red_led.start(0)

	pause_time = 0.010

	for i in range(0,100+1):

		red_led.ChangeDutyCycle(i)

		time.sleep(pause_time)

	for i in range(100,-1,-1):

		red_led.ChangeDutyCycle(i)

		time.sleep(pause_time)

	GPIO.cleanup()

dim()<br>

Step 4: Here Is the RESULT!

<p>Great Intro to Raspberry Pi tutorial.</p>
<p>Thank you for your feedback!</p>

About This Instructable

976views

4favorites

License:

More by al2code:Dim a LED with raspberry pi 3 and python 
Add instructable to: