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 led_status.py. 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:

  • https://www.coolcomponents.co.uk/raspberry-pi-3-model-b.html
  • http://www.rs-online.com/designspark/electronics/eng/blog/introducing-the-raspberry-pi-b-plus
  • https://www.raspberrypi.org/documentation/usage/gpio/
(30.04.2019 tarihinden itibaren toplam 59 kez, bugün 1 kez ziyaret edildi. )

Yorum Yap

Not - Bunları KullanabilirsinizHTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

gaziantep escort

süperbetin giriş