Cov txheej txheem:

Kev Sib Tham Xim Xim, Raws Li AIY Cov Khoom Siv Suab: 4 Cov Kauj Ruam
Kev Sib Tham Xim Xim, Raws Li AIY Cov Khoom Siv Suab: 4 Cov Kauj Ruam

Video: Kev Sib Tham Xim Xim, Raws Li AIY Cov Khoom Siv Suab: 4 Cov Kauj Ruam

Video: Kev Sib Tham Xim Xim, Raws Li AIY Cov Khoom Siv Suab: 4 Cov Kauj Ruam
Video: Sib Hawm Dhau (Time Passed) Music Video by: Deeda/Dib Xwb 2024, Hlis ntuj nqeg
Anonim
Kev Sib Tham Xim Xim, Raws Li AIY Lub Suab Khoom
Kev Sib Tham Xim Xim, Raws Li AIY Lub Suab Khoom
Kev Sib Tham Xim Xim, Raws Li AIY Lub Suab Cov Khoom
Kev Sib Tham Xim Xim, Raws Li AIY Lub Suab Cov Khoom
Kev Sib Tham Xim Xim, Raws Li AIY Lub Suab Khoom
Kev Sib Tham Xim Xim, Raws Li AIY Lub Suab Khoom
Kev Sib Tham Xim Xim, Raws Li AIY Lub Suab Khoom
Kev Sib Tham Xim Xim, Raws Li AIY Lub Suab Khoom

Tau kawm me ntsis txog Braille tsis ntev los no, Kuv xav tsis thoob yog tias kuv tuaj yeem tsim qee yam siv AIY lub suab rau Raspberry Pi, uas yuav muaj txiaj ntsig tiag tiag rau cov neeg tsis pom kev. Yog li tau piav qhia hauv qab no koj yuav pom tus qauv ntawm cov cuab yeej ntsuas xim yooj yim uas nyeem nws cov kev tshawb pom nrov nrov.

Qhov kev piav qhia ntau ntxiv ntawm cov kab ke no yuav muaj txiaj ntsig zoo rau cov neeg tsis pom kev lossis dig muag xim.

Lub kaw lus siv Raspberry Pi nrog AIY lub suab HAT txuas nrog. Ib qho TCS34725 RGB sensor tawg tau txuas nrog I2C chaw nres nkoj ntawm HAT. Qhov tawg tawm muaj lub ntsej muag sov sov dawb LED kom pom lub teeb kom raug tshuaj xyuas. Qhov kev tawm tsam tau muab tso rau hauv vaj tsev kom ua kom zoo dua qub thiab ua qauv ntsuas ntsuas.

Peb lub ntsuas xim ntsuas txog tib yam peb qib sib txawv raws li cov xim xim hauv koj lub qhov muag. Tom qab ntawd qhov liab, ntsuab thiab xiav (RGB) qhov tseem ceeb tau siv los laij cov xim tag nrho.

Qhov zoo ntawm qhov txheej txheem tshwj xeeb no yog tam sim no nws qhia koj cov xim hais lus, siv AIY lub suab khoom siv "hais" cov lus txib. Thov ua tib zoo saib ntawm daim vis dis aus nrog.

Cov cuab yeej kuj tseem yuav pab tau ua piv txwv rau I2C lub cuab yeej ntsuas txuas nrog AIY lub suab HAT.

Kauj Ruam 1: Cov Khoom Siv

Raspberry Pi 3. ~ 35 US $ lossis EUR

AIY cov khoom siv suab, nrog lub taub hau txuas rau HAT. ~ 25US $ lossis EUR

Adafruit TCS34725 tawg, nrog lub taub hau laug. ~ 8 US $ lossis EUR

Jumper cables.

Lub khob cij (xaiv tau)

Rau lub ntsuas cua nyob:- siv "Dolce Gusto" kas fes tshuaj ntsiav- ib puag ncig me me ntawm 2 hli Forex (PVC ua npuas ncauj phaj), txog 37 hli txoj kab uas hla- cov khoom tsis cuam tshuam dub los npog sab hauv phab ntsa ntawm lub tsev. Kuv siv tus kheej nplaum dub roj hmab ua npuas dej.

Yeem tau: hloov me me los ua kom pom qhov ntsuas

Ob peb tee ntawm cov kua nplaum yas thiab rab riam txiav.

Kauj ruam 2: Sib dhos thiab Siv

Sib dhos thiab Siv
Sib dhos thiab Siv
Sib dhos thiab Siv
Sib dhos thiab Siv
Sib dhos thiab Siv
Sib dhos thiab Siv

Raspberry Pi nrog AIY lub suab HAT tau teeb tsa raws li tau piav qhia hauv AIY phau ntawv. Ua ntej kev sib dhos, lub taub hau tau muab muag rau cov chaw nres nkoj ntawm HAT. Rau lub tsev nyob ntawm lub ntsuas cua, "Dulce Gusto" kas fes tshuaj ntsiav tau muab pov tseg, ntxuav, thiab ib feem ntawm hauv qab ua tib zoo tshem tawm nrog rab riam. Koj tuaj yeem siv lwm yam ntxiv rau lub hom phiaj no, lub khob kas fes tsuas yog muaj qhov loj thiab qhov zoo. Ib puag ncig daim ntawm 2mm Forex raug txiav los ntawm ib phaj, qhov kev tawm tsam tom qab ntawd tau muab tso rau hauv nruab nrab ntawm Forex phaj, txoj haujlwm tau cim nrog tus cwj mem, thiab lub qhov rau lub taub hau ntawm qhov tawg tau txiav ntawm txoj haujlwm tsim nyog.

Tam sim no daim Forex tau lo rau ntawm lub tsev thiab lub ntsuas hluav taws xob txuas nrog rau Forex phaj, siv Velcro sawb. Tom qab ntawd cov phab ntsa sab hauv tau npog nrog lub teeb nqus cov khoom dub, Kuv siv tus kheej-nplaum roj hmab ua npuas ncauj. Cov ntawv dub yuav tsum ua haujlwm ib yam nkaus. Tam sim no, siv jumper cables, I2C "3.3V" chaw nres nkoj ntawm HAT tau txuas nrog "V hauv" ntawm lub sensor, Hauv av rau Gnd, sda rau sda thiab scl rau scl. Kuv tau siv lub khob cij los txuas ob ntu, tab sis qhov ntawd tsis tseem ceeb.

Muab cov ntawv AIY_TCS34725 nab nab tso rau hauv src nplaub tshev thiab khiav cov ntawv los ntawm dev davhlau ya nyob twg, nkag mus "sec/AIY_TCS34752.py". Tej zaum koj yuav tsum ua kom cov ntawv nab hab sej ua haujlwm ua ntej. Thaum nug, tso lub ntsuas qhov ntsuas qhov ntsuas mus rau qhov ntsuas, nias lub pob hauv AIY ntaus ntawv thiab tos ib lossis ob lossis ob.

Tom qab ntawd, raws li ntsuas RGB thiab cov txiaj ntsig dawb, ntaus ntawv ua ntej suav qhov sib npaug qhov muaj nuj nqis, tom qab ntawd kwv yees xim raws tus nqi no thiab sib tham lawv hais lus ntawm AIY lub suab, e. g. raws li "liab liab", tab sis kuj tseem muab cov hue tus nqi. RGB, Hawj txawm thiab ci ntsa iab (qhov tseeb, kom raug) qhov tseem ceeb kuj tau luam tawm rau lub vijtsam.

Txhawm rau ua kom yooj yim cov txheej txheem piav qhia xim, RGB tus nqi tau hloov pauv mus rau HSV (hue, saturation, value) hom ntawv. Qhov no tso cai rau sau cov xim rau qee yam ntawm cov ces kaum (piv txwv li lub ncuav qab zib), thiab xaiv cov xim raws li kev suav cov xim hue.

Koj yuav tsum ua kom koj lub cuab yeej ua haujlwm tawm tsam dawb thiab siv dub. Tsuas yog ntsuas cov ntawv dawb tshaj plaws thiab dub tshaj plaws uas koj muaj, ntsuas txhua qhov, thiab tso cov txiaj ntsig no ua qhov siab tshaj plaws thiab yam tsawg kawg hauv qhov chaws. Tsuas yog kev pom zoo qhov txiaj ntsig yuav muab qhov paub xim zoo.

Ib qho teeb meem yooj yim yog kev xav. Yog tias koj muaj cov khoom uas muaj qhov ci lossis ci nws nws yuav cuam tshuam ntau lub teeb tawm los ntawm LED, tshwm ntau dua li qhov tiag tiag. Koj tuaj yeem siv daim ntawv ntawm daim nyias nyias kom tawg lub teeb, tab sis koj yuav tsum tau ua qhov kev hloov kho.

Nyob rau hauv cov ntaub ntawv ntawm cov khoom translucent, nws yuav siv tau los tso lawv rau ntawm daim ntawv dawb, txwv tsis pub tus nqi ntawm lub teeb pom kev yuav me me thiab cov khoom qhia tias "dub".

Yog tias koj xav ntsuas cov xim ntawm cov khoom uas tso tawm lub teeb, koj yuav tsum hloov lub LED ntawm qhov tawg los ntawm kev txuas "LED" chaw nres nkoj ntawm qhov tawg mus rau "Hauv av". Tam sim no teeb tsa cov txiaj ntsig zoo raws li.

Lwm qhov teeb meem dav dav yog qhov pom kev ntawm qhov khoom. Qhov sov sov dawb LED ntawm qhov tawg tawm ib qho tsis sib thooj ntawm lub teeb. Yog li qee yam xim yuav dhau los lossis tsis sawv cev hauv RGB spectrum. Yog xav paub ntau ntxiv txog cov ncauj lus no, thov saib kuv cov ntawv qhia yav dhau los ntawm cov xim/ yees duab thiab cov ntsuas ntsuas:

www.instructables.com/id/An-Inexpensive-Ph…

www.instructables.com/id/A-Mimimal-Six-Col…

Kauj Ruam 3: Txoj Cai

Txoj Cai
Txoj Cai

Cov cai yog ua ke ntawm kev hloov kho tus lej los ntawm AIY lub suab phau ntawv, thiab TCS34725 tus lej cim los ntawm Bradspi.

Kuv kuj tau sim siv TCS34725 nab nab chaws los ntawm Adafruit, tab sis muaj teeb meem khiav qhov no thiab qee lwm cov lej uas siv cov tsev qiv ntawv sab nraud ua ke nrog AIY HAT. Ib qho kev pab txais tos.

Raws li tau hais ua ntej, cov lus piav qhia xim yog raws kev hloov pauv ntawm RGB mus rau qhov tseem ceeb xim. Koj yuav tsum teeb tsa qhov qub raws li kev ntsuas ntsuas ntawm cov ntaub ntawv hwm dawb thiab dub. Ua kom tiav qhov tseem ceeb rau R, G thiab B min lossis max raws li.

Tsab ntawv siv qhov hloov tshiab ntawm "hais" cov lus txib uas tso cai tswj hwm ntim thiab suab. Nyob rau hauv rooj plaub, koj yuav tsum tau hloov kho audio.py thiab tty cov ntaub ntawv tsav tsheb lossis tshem tawm "ntim thiab suab ntu" los ntawm tsab ntawv.

"! #from gpiozero ntshuam LED # tuaj yeem pab tau rau sab nrauv LED ntawm servo-chaw nres nkoj #from gpiozero ntshuam khawm # tuaj yeem pab tau rau lub pob sab nraud ntawm servo-chaw nres nkoj ntshuam lub sijhawm ntshuam smbus npav = smbus. SMBus (1) ntshuam colorsys def hue2color (hue): # kev txhais xim raws qhov suav suav qhov tseem ceeb yog ((hue> 12) thiab (hue 25) thiab (hue 69) thiab (hue 164) thiab (hue 194) thiab (hue 269) thiab (hue 319) lossis (hue <20)): color = "red" return color else: print ("something went wrong")

def tcs34725 (): # ntsuas thiab txhais lus.

# Kev ntsuas ntsuas los ntawm Bradspi TCS34725 tsab ntawv: # https://bradsrpi.blogspot.com/2013/05/tcs34725-rg… bus.write_byte (0x29, 0x80 | 0x12) ver = bus.read_byte (0x29) # version # yuav tsum yog 0x44 yog tias ver == 0x44: print ("Device found / n") bus.write_byte (0x29, 0x80 | 0x00) # 0x00 = ENABLE register bus.write_byte (0x29, 0x01 | 0x02) # 0x01 = Power on, 0x02 RGB sensors qhib bus.write_byte (0x29, 0x80 | 0x14) # Nyeem cov txiaj ntsig pib sau npe 14, LSB tom qab ntawd MSB cov ntaub ntawv = bus.read_i2c_block_data (0x29, 0) clear = clear = data [1] << 8 | data [0] liab = data [3] << 8 | data [2] ntsuab = data [5] << 8 | data [4] xiav = data [7] << 8 | data [6] crgb = "suav tsis suav: C: %s, R: %s, G: %s, B: %s / n" %(meej, liab, ntsuab, xiav) luam tawm (crgb) time.sleep (1) lwm qhov: luam tawm ("Tsis pom lub cuab yeej / n") # kev hloov pauv thiab hloov pauv ntawm qhov ntsuas RGBW qhov ntsuas col = "" # Cov txiaj ntsig siab tshaj Qhov ua tau zoo, yuav tsum tau txhais ua piv txwv # piv txwv vs. ib daim ntawv dawb ntawv. Txheeb xyuas thiab kho raws sijhawm. max_bright = 5750 max_red = 1930 max_green = 2095 max_blue = 1980 # Background/Yam tsawg kawg qhov tseem ceeb ua kom zoo ib yam, yuav tsum tau txhais ua piv txwv # piv txwv li vs. daim ntawv dub. Txheeb xyuas thiab kho raws sijhawm. min_bright = 750 min_red = 340 min_green = 245 min_blue = 225 # qhov txiaj ntsig zoo, nruab nrab ntawm 0 thiab 1 rel_bright = ((meej - min_bright)/(max_bright - min_bright)) rel_red = ((liab - min_red)/(max_red - min_red)) rel_green = ((ntsuab - min_green)/(max_green - min_green)) rel_blue = ((xiav - min_blue)/(max_blue - min_blue)) hsv_col = colorsys.rgb_to_hsv (rel_red, rel_green, rel_blue) hue = hsv_col [0]*35 yog rel_bright> 0.9: col = "dawb" # yog qhov kaj heev -> dawb elif rel_bright dub ntxiv: col = hue2color (hue) # xaiv xim los ntawm cov xim muaj nuj nqis # luam tawm ("txheeb ze qhov tseem ceeb ci, liab, ntsuab, xiav:") # print (rel_bright, rel_red, rel_green, rel_blue) # print ("HSV values (hue, saturation, value):", hsv_col) # print ("hue in °", hue) return [col, rel_bright, rel_red, rel_green, rel_blue, hwv]

def lub ntsiab ():

khawm = aiy.voicehat.get_button () # hloov khawm xwm txheej coj = aiy.voicehat.get_led () # hloov khawm-LED xwm txheej aiy.audio.get_recorder (). pib () # buttoni = Khawm (5) # nrug deb sensor lossis lwm lub khawm sab nraud, txuas nrog servo3/GPIO 05

aiy.audio.say ("Nyob zoo!", ntim = 50, suab = 100) # ntim thiab suab xav tau Kaum Ib Hlis 2017 kev kho dua ntawm audio.py thiab _tty.py tus tsav tsheb!

aiy.audio.say ("Txhawm rau pib, txav lub ntsuas hluav taws xob siab dua qhov khoom. Tom qab ntawd nyem lub pob xiav", ntim = 50, suab = 100) luam tawm ("Txhawm rau qhib qhov ntsuas xim qhov chaw sensor saum toj no, tom qab ntawd nyem lub pob xiav) ") thaum Tseeb: led.set_state (aiy.voicehat. LED. ON) button.wait_for_press () # rau sab nraud khawm, hloov khawm los ntawm buttoni led.set_state (aiy.voicehat. LED. BLINK) aiy.audio.say (" Ntsuas ", ntim = 50, suab = 100) qhov tshwm sim = tcs34725 () # qhia txog kev ntsuas thiab txhais lus col = tshwm sim [0] # xim, raws li cov ntawv hue = str (int (tau (5))) # hue hauv °, as text r_red = str (int (result [2]*255)) # R value, as text r_green = str (int (result [3]*255)) # G value, as text r_blue = str (int (tshwm sim [4]*255)) # B tus nqi, raws li ntawv r_bright = str (int (tshwm sim [1]*100)) # W tus nqi, raws li cov ntawv nyeem.set_state (aiy.voicehat. LED. OFF) yog col == "dawb "lossis col ==" dub ": ci =" "elif (qhov tshwm sim [1]> 0.69): #ci ntsa iab/qhov ci ntawm cov xim ci =" teeb "elif (tshwm sim [1] <0.25): ci =" tsaus "lwm: ci = "nruab nrab" # sib tham t nws ua tiav color_text = ("Cov xim ntawm cov khoom yog" + ci ntsa iab "" + col) luam tawm (color_text) aiy.audio.say (color_text,, ntim = 75, suab = 100) hue_text = ("Tus hue tus nqi yog "+ hue+" degrees ") print (hue_text) aiy.audio.say (hue_text,, ntim = 75, suab = 100)

yog _name_ == '_main_': main ()

Kauj Ruam 4: Qee Qhov Txuas thiab Lus Cim

Daim ntawv TCS34725 sensor cov ntaub ntawv tuaj yeem nrhiav tau ntawm no:

Cov cai los nyeem lub ntsuas kuv tau siv tau piav qhia ntawm no:

Koj tuaj yeem pom qee cov ntaub ntawv ntxiv ntawm kev ntsuas xim nrog qhov no thiab lwm qhov ntsuas hauv kuv cov lus qhia yav dhau los:

www.instructables.com/id/An-Inexpensive-Ph…

www.instructables.com/id/A-Mimimal-Six-Col…

Pom zoo: