Cov txheej txheem:

Yuav Qhia Li Cas Cov Lus ntawm SenseHat: 5 Kauj Ruam
Yuav Qhia Li Cas Cov Lus ntawm SenseHat: 5 Kauj Ruam

Video: Yuav Qhia Li Cas Cov Lus ntawm SenseHat: 5 Kauj Ruam

Video: Yuav Qhia Li Cas Cov Lus ntawm SenseHat: 5 Kauj Ruam
Video: Muaj 5 nqis qhia txog cov hluas ua li cas thiaj tsim txiaj. 2024, Kaum ib hlis
Anonim
Yuav Qhia Li Cas Cov Lus ntawm SenseHat
Yuav Qhia Li Cas Cov Lus ntawm SenseHat

Nyob zoo, hnub no kuv yuav qhia koj yuav ua li cas tso saib cov lus ntawm Raspberry Pi SenseHat.

Kauj Ruam 1: Nqa Raspberry Pi

Hook Up Raspberry Pi
Hook Up Raspberry Pi

Ua ntej peb ua ib qho coding ntawm Raspberry Pi, peb yuav tsum txuas cov xov hlau zoo rau nws. Txuas lub HDMI cable rau hauv HDMI chaw nres nkoj, ntsaws lub zog, thiab txuas cov keyboard thiab nas rau nws. Yog tias koj xav tau, koj tuaj yeem txuas tus ethernet cable rau nws yog tias koj xav txuas rau Is Taws Nem. Txuas nws mus rau tus saib, thiab voila! Koj tuaj yeem nkag mus rau Raspberry Pi.

Kauj Ruam 2: Qhib Python 3 (IDLE)

Qhib Python 3 (IDLE)
Qhib Python 3 (IDLE)
Qhib Python 3 (IDLE)
Qhib Python 3 (IDLE)

Nyob rau sab laug saum toj kawg nkaus ntawm koj lub vijtsam, koj yuav tsum pom lub cim duab geometric raspberry. Nyem rau ntawm qhov ntawd, thiab qee qhov kev xaiv yuav los. Koj yuav tsum pom "Programming". Nyem rau qhov ntawd, thiab tom qab ntawd nyem rau "Python 3 (IDLE). Lub qhov rai yuav tsum qhib hu ua" Python 3.5.3 Plhaub

Kauj Ruam 3: Ntshuam SenseHat rau Python

Ntshuam SenseHat rau Python
Ntshuam SenseHat rau Python
Ntshuam SenseHat rau Python
Ntshuam SenseHat rau Python

Nyob rau sab laug sab saum toj ntawm lub qhov rais, ntaus (raws nraim li tau nyeem):

los ntawm sense_hat ntshuam SenseHat

Yog tias koj ua nws raug, qhov "los ntawm" thiab "ntshuam" yuav tsum yog txiv kab ntxwv. Nias nkag mus, thiab ntaus:

kev nkag siab = SenseHat ()

Nco ntsoov tias koj siv cov kab ntawv. Lawv qhia lub ntsiab lus txib.

Kauj Ruam 4: Tso Cov Lus

Zaub lus
Zaub lus

Nias sau ob zaug, tom qab ntawd ntaus:

sense.show_message ("Koj cov lus ntawm no")

Qhov ntawd yuav tsum yog nws! Koj cov lus yuav tsum tau tshwm ntawm lub vijtsam!

Kauj Ruam 5: Yeem Tsis Zoo

Yeem Teeb Meem
Yeem Teeb Meem

Yog tias koj xav tau txais qhov zoo nkauj ntxiv, koj tuaj yeem hloov qhov nrawm, xim ntawv, thiab xim tom qab ntawm cov lus.

Txhawm rau hloov cov ntawv nrawm, sau cov lus txib zoo li no:

sense.show_message ("koj cov lus ntawm no", text_speed = random#)

1 yog lub nrawm nrawm.

Txhawm rau hloov cov xim ntawm koj cov ntawv lossis keeb kwm yav dhau, koj yuav tsum teeb tsa RGB hloov pauv ua ntej. RGB hloov pauv yog xim, thiab koj teeb lawv zoo li no:

r = (255, 0, 0) cov

Thawj tus lej yog tus nqi liab, ntsuab thib ob, thiab xiav thib peb. Tom qab teeb tsa qhov hloov pauv, sau cov lus txib zoo li no:

sense.show_message ("koj cov lus ntawm no", text_colour = sib txawv, back_colour = sib txawv)

Koj tuaj yeem ua ke ib qho ntawm cov lus txib no kom hloov pauv koj cov lus.

Pom zoo: