Cov txheej txheem:
- Kauj ruam 1: Kho vajtse
- Kauj ruam 2: Teeb Kho Vajtse
- Kauj Ruam 3: Software - Arduino IDE, PyCharm IDE
- Kauj Ruam 4: Arduino IDE
- Kauj Ruam 5: Arduino IDE - Txoj Cai Tshooj 1
- Kauj Ruam 6: Arduino IDE - Txoj Cai Tshooj 2
- Kauj Ruam 7: Qhib PyCharm IDE thiab Nyem rau File -> Settings
- Kauj Ruam 8: Hauv Txoj Haujlwm, Xaiv Txoj Haujlwm Txhais Lus thiab Nyem rau "+" Icon
- Kauj Ruam 9: Hauv Qhov Tshawb Nrhiav, Ntaus Pyserial thiab Nyem rau Nruab Pob
- Kauj Ruam 10: Tus nab npawb nab npawb hauv qab yog Khiav ntawm PyCharm IDE
- Kauj Ruam 11: Python Code - Ntu 1
- Kauj Ruam 12: Python Code - Ntu 2
- Kauj Ruam 13: Kawg
- Kauj ruam 14: Yees duab
Video: Python (pySerial) + Arduino + DC Tsav: 14 Cov Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:26
Phau ntawv qhia ceev no qhia txog kev ua haujlwm yooj yim ntawm DC lub cav siv Python GUI. Txhawm rau Python los tham nrog Arduino pawg thawj coj saib peb yuav siv pob pySerial. pySerial yog Python lub tsev qiv ntawv uas muab kev txhawb nqa rau kev sib txuas txuas nrog ntau yam khoom siv sib txawv.
Kauj ruam 1: Kho vajtse
Adafruit lub cev tiv thaiv kab mob, Arduino board (Mega), DC lub cev muaj zog, 1k ohm resistors (2), LEDs (2), sib txuas xov hlau thiab daim txiag ntoo.
Kauj ruam 2: Teeb Kho Vajtse
Hauv qhov teeb tsa no, ntsuab LED -> Tus Pin 30 ntawm Arduino boardred LED -> Tus pin 32 ntawm Arduino boardDC Tsav -> Channel 3 (M3) ntawm lub cev muaj zog tiv thaiv
Kauj Ruam 3: Software - Arduino IDE, PyCharm IDE
Kauj Ruam 4: Arduino IDE
Txuas qhov xav tau Arduino board rau PC (qhov no kuv siv Arduino Mega). Qhib Arduino IDE thiab xaiv qhov tsim nyog COM chaw nres nkoj thiab pawg thawj coj saib. Cov cai hauv qab no tau xa mus rau Arduino pawg tswj hwm los ntawm nyem rau ntawm Upload khawm.
Kauj Ruam 5: Arduino IDE - Txoj Cai Tshooj 1
Kauj Ruam 6: Arduino IDE - Txoj Cai Tshooj 2
Kauj Ruam 7: Qhib PyCharm IDE thiab Nyem rau File -> Settings
Cov chaw. "Src =" https://content.instructables.com/ORIG/F2U/HXFW/K0MP3QX8/F2UHXFWK0MP3QX8-p.webp
Chaw. "Src =" {{file.large_url | ntxiv: 'pib = webp & thav duab = 1 & qhov siab = 300' %} ">
Kauj Ruam 8: Hauv Txoj Haujlwm, Xaiv Txoj Haujlwm Txhais Lus thiab Nyem rau "+" Icon
Kauj Ruam 9: Hauv Qhov Tshawb Nrhiav, Ntaus Pyserial thiab Nyem rau Nruab Pob
Kauj Ruam 10: Tus nab npawb nab npawb hauv qab yog Khiav ntawm PyCharm IDE
Kauj Ruam 11: Python Code - Ntu 1
NCO TSEG: Nco ntsoov tib tus lej COM chaw nres nkoj tau siv hauv Python code. References: pySerial: https://pyserial.readthedocs.io/en/latest/shortintro.htmlTkinter: https://docs.python.org/3/ tsev qiv ntawv/tkinter.html#tkinter-modules
Kauj Ruam 12: Python Code - Ntu 2
Kauj Ruam 13: Kawg
Ib qho yooj yim GUI qhib nrog 3 khawm - FORWARD, REVERSE thiab EXIT. Nyob ntawm seb lub cav txuas hluav taws xob txuas, lub cav khiav hauv qhov kev xav tau nrog nias ntawm FORWARD lossis REVERSE khawm. Lub pob EXIT kaw qhov chaw nres nkoj txuas thiab xaus qhov kev ua haujlwm tiav.