Etiket Arşivi raspberry pi blink led

Raspberry Pi 3 Model B Turn on and off Led

Connect led to Raspberry Pi as shown below (I used GPIO 20 port, also you can use another GPIO port but, you must point out this port in the python file).


Then open a text document, named it Then write the codes below in it.

import RPi.GPIO as GPIO

def set_led(status):
        led = 20
        GPIO.setup(led, GPIO.OUT)
        GPIO.output(led, status)

Run the script by the command below;

to turn on the led  python  -c ‘import led_status; led_status.set_led(1)’

to turn off the led python -c ‘import led_status; led_status.set_led(0)’


Sources for pictures: