Cov txheej txheem:

Raspberry Pi Tutorial ntawm LED Blinking: 4 Cov Kauj Ruam
Raspberry Pi Tutorial ntawm LED Blinking: 4 Cov Kauj Ruam

Video: Raspberry Pi Tutorial ntawm LED Blinking: 4 Cov Kauj Ruam

Video: Raspberry Pi Tutorial ntawm LED Blinking: 4 Cov Kauj Ruam
Video: Course Lesson 4 of 10: Raspberry Pi Pico Expansion board for 4WD Smart Car Kit 2024, Hlis ntuj nqeg
Anonim
Image
Image

Yuav tsum tau:

  • Raspberry Pi
  • BreadBoard lossis T-Cobbler
  • Jumper Hlau
  • LED

Nyem rau qhov no Yog Xav Paub Ntxiv

Kauj Ruam 1: Txuas Koj Raspberry Pi GPIO Nrog LED ntawm Breadboard lossis Pawg Thawj Coj Ua Haujlwm

Teeb
Teeb

Tam sim no raws li cov vis dis aus koj tuaj yeem siv tus lej tus lej 27 raws li tso tawm thiab txuas GND nrog coj GND davhlau ya nyob twg, Nco ntsoov tias koj qhov kev sib txuas GPIO yuav tsum raug.

Kauj ruam 2: Teeb

Txuas LED ntawm breadbard lossis T-cobbler raws li txuas video.

Kauj Ruam 3: Nruab GPIO Libraries

$ sudo apt-tau hloov tshiab

$ sudo apt-tau nruab python-rpi.gpio python3-rpi.gpio

Kauj Ruam 4: Txoj Haujlwm

ntshuam RPi. GPIO ua GPIO

lub sij hawm ntshuam

LedPin = 11 # pin11

def teeb tsa ():

GPIO.setmode (GPIO. BOARD) # Tus lej GPIOs los ntawm qhov chaw nyob

GPIO.setup (LedPin, GPIO. OUT) # Teeb LedPin hom yog tso tawm

GPIO.output (LedPin, GPIO. HIGH) # Teeb LedPin siab (+3.3V) kom tig rau coj

def ntsais ():

thaum Muaj Tseeb:

GPIO.output (LedPin, GPIO. HIGH) # coj mus

tsaug zog (1)

GPIO.output (LedPin, GPIO. LOW) # coj tawm sijhawm.sleep (1)

def rhuav tshem ():

GPIO.output (LedPin, GPIO. LOW) # coj tawm

GPIO.cleanup () # Tso peev txheej

yog _name_ == '_main_':

teeb ()

sim:

ntsais muag ()

tshwj tsis yog KeyboardInterrupt:

rhuav tshem ()

Pom zoo: