Cov txheej txheem:
- Khoom siv
- Kauj ruam 1: Khiav Terminal Emulator
- Kauj Ruam 2: Txuas SPIKE Prime rau USB Port
- Kauj Ruam 3: Nrhiav Chaw Nres Nkoj
- Kauj ruam 4: Txuas Txuas
- Kauj Ruam 5: Pib REPL
- Kauj Ruam 6: Koj Thawj Txoj Cai
- Kauj Ruam 7: Qhia Koj Lub Npe
- Kauj Ruam 8: Siv REPL
- Kauj Ruam 9: Tshawb MicroPython ntawm SPIKE Prime
- Kauj Ruam 10: Nyeem Sensor Qhov Muaj Nqes… 1
- Kauj Ruam 11: Nyeem Sensor Qhov Muaj Nqes… 2
- Kauj Ruam 12: Sib tw
Video: MicroPython ntawm SPIKE Prime: 12 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:25
Koj tuaj yeem ua tus lej SPIKE Prime siv MicroPython uas yog ntu me me ntawm nab nab rau me me microprocessors.
Koj tuaj yeem siv ib lub davhlau ya nyob twg emulator rau code SPIKE Prime hub.
Khoom siv
SPIKE Prime hub
Khoos phis tawj nrog USB Port / bluetooth
USB cable txuas lub hub rau lub khoos phis tawj
Kauj ruam 1: Khiav Terminal Emulator
Muaj ntau txoj kev xaiv los ntawm.
CoolTerm ua haujlwm ntawm txhua lub platform, suav nrog Pi
Putty ua haujlwm ntawm lub qhov rais
screen hais kom ua hauv Terminal ntawm lub unix operating system
Kauj Ruam 2: Txuas SPIKE Prime rau USB Port
Siv lub microUSB cable txuas SPIKE Prime rau lub khoos phis tawj.
Kauj Ruam 3: Nrhiav Chaw Nres Nkoj
Peb yuav tsum paub dab tsi qhov chaw nres nkoj txuas SPIKE Prime hub txuas nrog.
Hauv mac, ntaus ntawv
ls /dev/tty.usbmodem*
Ntawm lub pc, saib hauv koj tus thawj tswj ntaus ntawv hauv qab kab ntawv kom pom cov chaw nres nkoj twg koj tau txuas nrog
Ntawm pi, nws yuav yog qee yam xws li ttyAMC0 - txheeb xyuas hauv koj /dev /nplaub tshev
Kauj ruam 4: Txuas Txuas
Txuas mus rau qhov chaw nres nkoj raug (los ntawm cov kauj ruam dhau los) ntawm 115200 baud
Hauv Terminal, ntaus ntawv
usercomputer $ screen / dev / 115200
Hauv lwm qhov IDE, ntaus qhib/ txuas (tom qab teeb tsa cov chaw nres nkoj thiab baudrates)
Nco tseg: tsis muaj qhov sib npaug, 8 cov ntaub ntawv me me, thiab 1 nres me ntsis
Kauj Ruam 5: Pib REPL
Thaum koj txuas rau SPIKE Prime los ntawm lub davhlau ya nyob twg/ PUTTY koj yuav pom cov kwj ntawm cov lej thiab cov cim. Cov no yog cov ntaub ntawv los ntawm sab hauv lub cim xeeb ntawm SPIKE Prime hub. Txhawm rau pib nias tswj + c
Nws yuav cuam tshuam qhov chaw nres nkoj thiab koj yuav tsum pom qee yam zoo li no.
MicroPython v1.9.4-1146-gca9944357 ntawm 2019-09-25; LEGO Technic Loj Hub nrog STM32F413xx Hom "pab ()" kom paub ntau ntxiv.
Tam sim no koj npaj txhij rau code.
Kauj Ruam 6: Koj Thawj Txoj Cai
ntshuam hub
hub.display.show ('Tufts')
Pom qhov "ntshuam" hais kom ua - uas rub hauv lub tsev qiv ntawv nab nab uas cia koj tham nrog SPIKE Prime. Koj yuav tsum pom Tufts sau rau ntawm LED matrix ntawm lub hub.
Kauj Ruam 7: Qhia Koj Lub Npe
tam sim no sim ntaus ntawv
hub.display.show ('')
nco ntsoov tias txij li koj twb tau xa cov hub saum toj no, nws twb tau nco lawm. Yog tias nws tsis yog, koj yuav tau txais qhov yuam kev xws li:
Rov qab (hu xov tooj tsis ntev los no): Cov ntaub ntawv "", kab 1, inNameError: lub npe 'hub' tsis tau txhais
Kauj Ruam 8: Siv REPL
Ib qho ntawm cov yam ntxwv muaj zog ntau dua ntawm Python yog tias koj tuaj yeem sim txhua yam tawm ua ntej sau cov cai hauv REPL (nyeem ntsuas ntsuas luam tawm lub voj).
Nws yuav ua ib qho lus txib nab nab - sim ntaus 2 + 2 hauv qab no thiab saib nws hais dab tsi:
2+2
Kauj Ruam 9: Tshawb MicroPython ntawm SPIKE Prime
Tam sim no nws yog lub sijhawm los tshawb nrhiav.
hub muaj ntau txoj haujlwm - koj tuaj yeem paub los ntawm kev ntaus "hub." (tsis txhob hnov qab lub sijhawm tom qab lub hub) thiab tom qab ntawd tsoo tus lej TAB hauv REPL. Qhov ntawd yuav qhia koj txhua txoj hauv kev sib txawv uas koj tuaj yeem ua tiav cov lus txib.
Kev sib tw: Saib seb koj puas tuaj yeem nyeem nrawm dua.
Kauj Ruam 10: Nyeem Sensor Qhov Muaj Nqes… 1
Cov ntaub ntawv nrawm tau rov qab los raws li qhov muaj nuj nqis. yog li yog tias koj tsuas xav tau tus nqi X, koj tuaj yeem sim
hub.motion.accelerometer () [0]
lossis txoj hauv kev zoo dua rau tus lej no yuav yog siv cov lej zoo li no:
ntshuam hub
accel = hub.motion.accelerometer () xAccel = accel [0] hub.display.show (str (xAccel))
Kauj Ruam 11: Nyeem Sensor Qhov Muaj Nqes… 2
Koj kuj tseem tuaj yeem tso tawm tag nrho peb qhov nrawm siv lub voj.
Peb tseem yuav ntshuam lub tsev qiv ntawv siv sijhawm kom peb tuaj yeem ncua thiab muab sijhawm rau koj los nyeem tus lej ntawm lub vijtsam.
Sim cov cai no:
ntshuam hub, utimeaccel = hub.motion.accelerometer () rau Acc hauv accel: hub.display.show (str (Acc)) utime.sleep (0.8)
Hauv qhov no, ob peb yam tseem ceeb:
qhov chaw - Python yog txhua yam hais txog kev nkag mus rau sab xis - zoo ib yam li cov kab sib dhos hauv lwm yam lus, kev nkag mus qhia rau koj paub dab tsi yog sab hauv rau lub voj thiab dab tsi tsis yog.
thaum siv REPL, koj yuav pom tias thaum koj nkag mus, nws tsis ua txoj kab ntxiv lawm tab sis tos kom koj ua tiav cov kab rau lub voj ua ntej ua tiav (thiab >>> yog hloov los ntawm …). Txhawm rau ua kom tiav rau lub voj, tsuas yog ntaus rov qab peb zaug thiab lub voj yuav ua tiav.
Kauj Ruam 12: Sib tw
Tom ntej no, saib yog tias koj tuaj yeem txheeb xyuas seb cov cai hauv qab no ua li cas - thiab sim ua nws kom pom tias koj raug.
import hub, siv
thaum muaj tseeb: accel = hub.motion.accelerometer () rau Acc hauv accel: hub.display.show (str (Acc)) utime.sleep (0.8) yog hub.port. B.device.get (): so
Hint -Koj xav tau lub sensor ntawm chaw nres nkoj B.
Pom zoo:
Plotting Real-time Graph ntawm Android Los Ntawm Arduino Los Ntawm HC-05: 3 Cov Kauj Ruam
Plotting Real-time Graph ntawm Android Los ntawm Arduino Los ntawm HC-05: Hav nyob ntawm no, ntawm no yog kev qhia qhia yuav ua li cas npaj cov phiaj xwm ntawm lub sijhawm tiag tiag ntawm qhov tseem ceeb los ntawm tus tswj hwm micro xws li Arduino rau lub app. Nws siv Bluetooth qauv xws li HC-05 los ua lub cuab yeej xa xov mus rau kis thiab tau txais cov ntaub ntawv ntawm Ar
Tsim thiab Ua tiav ntawm Cov Txheej Txheem ntawm Kev Taw Qhia ntawm Photovoltaic Panels: 5 Cov Kauj Ruam
Tsim thiab Ua kom tiav ntawm Cov Txheej Txheem ntawm Kev Taw Qhia ntawm Photovoltaic Panels: Tsim thiab Ua tiav ntawm Cov Txheej Txheem ntawm Kev Taw Qhia ntawm Photovoltaic Panels
Kev tswj hwm tus kheej ntawm RPM ntawm Lub Cav Siv Lub Tswv Yim Los Ntawm IR Raws Li Tachometer: 5 Cov Kauj Ruam (nrog Duab)
Kev Tswj Tus Kheej ntawm RPM ntawm Lub Cav Siv Lub Tswv Yim Los Ntawm IR Raws Lub Tachometer: Muaj ib txwm xav tau rau kev siv tshuab txheej txheem, ua nws yooj yim/tsis txaus ntseeg. cov txheej txheem rau dej/siv dej rau peb daim av me me.Qhov teeb meem ntawm tsis muaj kab khoom siv tam sim no
Zaub Cov Duab Tawm ntawm PSP/Lub Xov Tooj Ntawm Lub Xov Tooj Ntawm Digital Duab: 3 Kauj Ruam
Zaub Cov Duab Tawm PSP/Lub Xov Tooj Ntawm Lub Xov Tooj Ntawm Tus Duab: Zoo … lub npe hais tias txhua yam tiag tiag … Qhov no yog qhov qhia tau yooj yim heev thiab nws tsis xav tau kho vajtse lossis software ntau dua li koj yuav tsum muaj ! Cov Lus Nug Qhia Rau Kuv lossis Tawm Tswv Yim! Koj tsis tas yuav hloov kho kom ua
Cov lus qhia ntawm Kev Ua Kom Zoo Mock-Up ntawm Track Slide Tsim rau Nqa/Txo Hauv Pem Hauv Ntej-Mounted Footrests ntawm Lub Hwj Huam Log: 9 Kauj Ruam (nrog Duab)
Cov lus qhia ntawm Kev Ua Kom Tiav Mock-Up ntawm Track Slide Tsim rau Nqa/Sab Qaum Nruab Nrab-Mounted Footrests ntawm Lub Hwj Huam Lub Rooj Zaum: Lub hauv paus tau teeb tsa lub tog zaum kom nqa tau hauv qab lub rooj kom zoo, thiab qis dua kom siv tau. Ib lub tswv yim rau kev ua haujlwm ywj pheej ntawm kev tuav cov footrest thiab kev xa tawm tsis suav nrog lub rooj zaum fais fab lag luam, thiab PWC cov neeg siv tau qhia txog qhov xav tau