Cov txheej txheem:

Automated Photobooth: 4 Kauj Ruam (nrog Duab)
Automated Photobooth: 4 Kauj Ruam (nrog Duab)

Video: Automated Photobooth: 4 Kauj Ruam (nrog Duab)

Video: Automated Photobooth: 4 Kauj Ruam (nrog Duab)
Video: She Gets A SURPRISE! 😱 2024, Hlis ntuj nqeg
Anonim
Tsis siv neeg Photobooth
Tsis siv neeg Photobooth

Qhov no yuav qhia koj yuav ua li cas thiaj ua lub rooj muag khoom yees duab siv lub raspberry pi, lub ntsuas hluav taws xob nrug deb deb, thiab ob peb lwm yam khoom siv ntxiv. Kuv xav ua ib qhov haujlwm uas siv ob yam khoom siv khoos phis tawj thiab ib txoj haujlwm uas siv tau zoo. Kuv tshawb fawb cov phiaj xwm zoo li no ntawm nplooj ntawv raspberry pi cov peev txheej, qee qhov ntawm cov haujlwm no yog kev suav lub cev nrog nab hab sej, thiab micro me selfie. Ib qho ntawm no tau qhia tias yuav siv lub koob yees duab raspberry pi li cas thiab lwm qhov pom tias yuav siv lub tshuab ntsuas nrug deb li cas.

Kauj ruam 1: Cov ntaub ntawv

Khoom siv
Khoom siv

Ua ntej peb pib tsim peb lub voj voog koj yuav xav tau qee cov ntaub ntawv:

1 x Raspberry Pi 3

1 x T-Cobbler

1 x Pi Lub Koob Yees Duab

1 x Ultrasonic Distance Sensor

3 x RGB LEDs

10 x 330 Ohms Resistors

1 x 560 Ohms Resistor

5 x Spool ntawm cov xim sib txawv xim

1 x Breadboard

Kauj ruam 2: Tsim lub Circut

Tsim lub Circut
Tsim lub Circut
Tsim lub Circut
Tsim lub Circut
Tsim lub Circut
Tsim lub Circut
Tsim lub Circut
Tsim lub Circut

Nov yog txoj hauv kev uas kuv tau mus txog txuas kuv lub Circuit:

1. Txhawm rau ua qhov Circuit no koj yuav xav ntsaws lub koob yees duab Raspberry Pi rau lub qhov (socket) uas tsim nyog

2. ntsaws T-Cobbler rau ntawm daim ntawv tais.

3. Siv kev cai ntev jumper cables txuas ib qho rau txoj kev tsheb nqaj hlau thiab ib qho mus rau txoj kev tsheb nqaj hlau

4. Ntsaws rau hauv qhov ntsuas nrug deb deb thiab ntsaws 'vcc' txhais ceg rau hauv hwj chim, 'gnd' rau hauv av, 'trig' rau hauv GPIO tus pin, thiab 'ncho' rau hauv 330 ohms resistor uas txuas rau 560 ohms resistor uas txuas nrog hauv av thiab tus lej GPIO.

5. Muab peb lub RGB LEDs tso rau ntawm lub khob cij txuas hauv qab txuas lub anode ntawm LEDs rau lub zog, thiab txuas cov ceg sib txawv uas tswj cov xim ntawm LEDs rau 330 ohms resistors thiab tom qab ntawd mus rau GPIO pins.

Kauj Ruam 3: Txoj Cai

Txhawm rau kom muaj Raspberry Pi siv GPIO pins peb yuav xav tau tus lej pins ua qee yam. Txhawm rau ua tus lej uas kuv tau ua kuv siv sej 3 IDLE. Cov cai uas kuv tau ua siv RPi. GPIO ntxiv rau lub tsev qiv ntawv gpiozero kom ua haujlwm. Muaj cov txheej txheem rau cov xim sib txawv thiab muaj lub luag haujlwm uas suav qhov nrug deb uas siv lub ntsuas nrug deb nrug deb thiab thaum muaj qee yam hauv nws nws yuav qhib lub koob yees duab pi saib ua ntej thiab LEDs yuav suav rov qab thiab tom qab ntawd tau thaij duab.

Nov yog tus lej uas kuv siv:

los ntawm picamera ntshuam PiCamera los ntawm gpiozero ntshuam khawm, LED los ntawm lub sijhawm ntshuam ntshuam ntshuam RPi. GPIO li GPIO lub sijhawm ntshuam

r = [LED (23), LED (25), LED (12)]

g = [LED (16), LED (20), LED (21)] b = [LED (17), LED (27), LED (22)] khawm = Khawm (24) GPIO.setmode (GPIO. BCM) GPIO_TRIGGER = 19 GPIO_ECHO = 26 GPIO.setup (GPIO_TRIGGER, GPIO. OUT) GPIO.setup (GPIO_ECHO, GPIO. IN)

def liab (x):

r [x].off () g [x].on () b [x].on ()

def tawm (x):

r [x].on () g [x].on () b [x].on ()

def tawm ():

r [0].on () g [0].on () b [0].on () r [1].on () g [1].on () b [1].on () r [2].on () g [2].on () b [2].on ()

def ntsuab (x):

r [x].on () g [x].off () b [x].on ()

def xiav (x):

r [x].on () g [x].on () b [x].off ()

def khiav ():

camera.capture ('selfie.jpg') camera.stop_preview ()

def nrug ():

GPIO.output (GPIO_TRIGGER, True) time.sleep (0.00001) GPIO.output (GPIO_TRIGGER, Cuav) StartTime = time.time () StopTime = time.time () thaum GPIO.input (GPIO_ECHO) == 0: StartTime = sijhawm.time () thaum GPIO.input (GPIO_ECHO) == 1: StopTime = time.time () TimeElapsed = StopTime - StartTime nrug = (TimeElapsed *34300) / 2 rov qab nrug

tawm ()

thaum muaj tseeb: d = nrug () yog int (d) <= 30: nrog PiCamera () raws li lub koob yees duab: camera.start_preview () liab (0) pw (1) xiav (1) pw (1) ntsuab (2) pw (1) tawm () camera.capture ('selfie.jpg') camera.stop_preview ()

Pom zoo: