Cov txheej txheem:
- Khoom siv
- Kauj ruam 1: Kho vajtse
- Kauj Ruam 2: Txheeb Xyuas Nws Yuav Tsum Ua Haujlwm Li Cas
- Kauj Ruam 3: cuam tshuam nrog Lub Xeev Tshuab
- Kauj Ruam 4: HMI Tswj
- Kauj Ruam 5: Tuav Xeev
- Kauj ruam 6: Stopwatch
- Kauj Ruam 7: Txee
- Kauj Ruam 8: Simulation
- Kauj Ruam 9: Tau Piv Txwv
Video: Arduino HMI Siv Lub Xeev Machine: 9 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:26
Hauv Cov Lus Qhia no, Kuv yuav qhia koj yuav siv YAKINDU Daim Ntawv Qhia Xeev Li Cas kom paub qhov yooj yim thiab nthuav dav HMI los ntawm kev siv 16x2 LCD Keypad Shield rau Arduino.
Finite State Machines (FSM) yog tus qauv tsim muaj zog los tsim cov Tib Neeg Lub Tshuab Sib Txuas (HMI). Raws li kev ua haujlwm ntawm HMI tuaj yeem nce ntxiv, nws muaj txiaj ntsig zoo los siv cov qauv tsim qauv zoo li lub xeev cov tshuab.
Qhov ua piv txwv tiav yog kos rau hauv YAKINDU Statechart Cov Cuab Yeej. Ib qho ntxiv, Eclipse C ++ IDE rau Arduino Plugin tau siv los ua ke thiab ua rau pom hauv IDE.
Cov Lus Qhia luv luv ntawm YAKINDU Cov Ntawv Qhia Hauv Xeev
Nrog rau cov cuab yeej no, nws muaj peev xwm los tsim cov tshuab hauv xeev. Nws tso cai rau tus neeg siv tsim C, C ++ lossis Java code los ntawm lub xeev tshuab. Nrog rau txoj hauv kev no, tus qauv tuaj yeem hloov pauv lossis nthuav dav thiab tus neeg siv tuaj yeem yooj yim rov tsim cov cai thiab tsis tas yuav sau qhov chaws yooj yim.
Khoom siv
Qhov:
- Arduino (Ua, Mega)
- USB Cable
- 16x2 LCD Keypad Shield
Cov Cuab Yeej:
- YAKINDU Statechart Cov Cuab Yeej
- Dab noj hnub C ++ IDE rau Arduino
Kauj ruam 1: Kho vajtse
LCD Keypad Shield tuaj yeem yooj yim ntsaws rau hauv Arduino. Nws muaj 16x2 LCD Zaub thiab ntxiv tau rau rau lub khawm:
- Sab laug
- Txoj cai
- Saum
- Nqis
- Xaiv
- (Pib dua)
Pom tseeb, tsib ntawm lawv tuaj yeem siv tau. Cov yuam sij tau xaim mus rau qhov sib faib hluav taws xob thiab kuaj pom los ntawm kev siv Pin A0 nyob ntawm qhov hluav taws xob. Kuv tau siv software debouncing los txheeb xyuas lawv kom raug.
Kauj Ruam 2: Txheeb Xyuas Nws Yuav Tsum Ua Haujlwm Li Cas
Daim ntawv thov yuav tsum muaj peev xwm ua peb yam.
- Kuaj Lub Xeev Ntawm no Kuv xav siv cov nyees khawm los ntawm tsib lub xeev: Sab Saum, Nruab Nrab, Hauv Qab, Sab laug thiab Txoj Cai
- Stopwatch Lub moos yooj yim, uas tuaj yeem pib, nres thiab rov pib dua. Nws yuav tsum tau nce ntxiv txhua 100 milliseconds
- CounterQhov thib peb muaj qhov yooj yim nce/nqis txee. Nws yuav tsum muaj peev xwm suav tus lej zoo thiab nws yuav tsum rov teeb tsa tau
Cov ntawv qhia zaub mov nquag (lossis lub xeev) yuav tshwm rau ntawm 16x2 LCD ntawm kab saum toj kawg nkaus. Daim ntawv thov (Xeev, Timer lossis Counter) yuav muab tso rau ntawm kab hauv qab. Txog kev taw qhia, yuav tsum siv lub pob nyem sab laug thiab sab xis.
Kauj Ruam 3: cuam tshuam nrog Lub Xeev Tshuab
Cov nyees khawm yuav raug nthuav tawm thiab txuas mus rau lub xeev tshuab. Lawv tuaj yeem siv tau raws li cov xwm txheej hauv lub xeev tshuab. Ib qho ntxiv, cov haujlwm tau piav qhia kom pom cov ntawv qhia zaub mov tam sim no. Thiab tsawg kawg ob qhov sib txawv, ib qho rau lub sijhawm thiab ib qho rau lub txee, tau hais tseg.
interface:
// cov nyees khawm raws li cov xwm txheej hauv qhov xwm txheej sab xis hauv qhov tshwm sim hauv qhov xwm txheej hauv qhov xwm txheej xaiv // tso saib HMI cov txiaj ntsig tshwj xeeb ua haujlwm displayLCDString (tus nqi: hlua, ntev: integer, txoj haujlwm: integer) ua haujlwm displayLCDInteger (tus nqi: integer, txoj haujlwm: integer) lag luam clearLCDRow (txoj hauj lwm: integer) sab hauv: // hloov pauv rau cia var cnt: integer var timeCnt: integer = 0
Tom qab tsim cov cai C ++, cov xwm txheej yuav tsum tau nthuav tawm thiab txuas mus rau lub interface. Tsab ntawv xov xwm no qhia pom yuav ua li cas.
Thaum xub thawj, cov nyees khawm yuav raug txhais:
#define NONE 0 #txhais SELECT 1 #define LEFT 2 #define DOWN 3 #define UP 4 #define RIGHT 5
Tom qab ntawd muaj lub luag haujlwm txhais los nyeem lub pob. Tus nqi yuav txawv, nyob ntawm tus tsim LCD Shield.
zoo li qub int readButton () {int tshwm sim = 0; tau = analogRead (0); yog (qhov tshwm sim <50) {rov qab RIGHT; } yog (qhov tshwm sim <150) {rov qab UP; } yog (qhov tshwm sim <300) {rov qab DOWN; } yog (qhov tshwm sim <550) {rov qab LEFT; } yog (qhov tshwm sim <850) {rov SELECT; } rov tsis muaj; }
Thaum kawg, cov nyees khawm yuav raug nthuav tawm. Kuv tau ua tiav zoo nrog 80 ms. Thaum lub pob yuav raug tso tawm, nws yuav nce raws li qhov tshwm sim.
int oldState = TSIS MUAJ; zoo li qub tsis muaj dabtsis nceEvents () {int buttonPressed = readButton (); ncua (80); oldState = khawm khawm; if (oldState! = NONE && readButton () == NONE) {hloov (oldState) {case SELECT: {stateMachine-> raise_select (); tawg; } rooj LEFT: {stateMachine-> lift_left (); tawg; } case DOWN: {stateMachine-> raise_down (); tawg; } rooj plaub UP: {stateMachine-> raise_up (); tawg; } rooj plaub RIGHT: {stateMachine-> raise_right (); tawg; } default: {tawg; }}}}
Kauj Ruam 4: HMI Tswj
Txhua lub xeev tau siv rau ib feem ntawm cov ntawv qhia zaub mov. Muaj cov xeev me, qhov twg daim ntawv thov - piv txwv li lub moos nres - yuav ua tiav.
Nrog rau qhov kev tsim no, lub interface tuaj yeem nthuav dav tau yooj yim. Cov ntawv ntxiv tuaj yeem yooj yim ntxiv los ntawm kev siv tib tus qauv tsim. Nyeem tus nqi ntawm lub ntsuas thiab pom nws hauv kab ntawv thib plaub yam tsis muaj teeb meem loj.
Txog tam sim no, tsuas yog sab laug thiab sab xis yog siv los ua kev tswj hwm. Tab sis nce thiab nqis kuj tseem tuaj yeem siv ua qhov txuas ntxiv hauv cov ntawv qhia zaub mov tseem ceeb. Tsuas yog khawm xaiv yuav raug siv los nkag rau cov khoom tshwj xeeb.
Kauj Ruam 5: Tuav Xeev
Lub xeev cov ntawv qhia zaub mov tsuas yog siv ua piv txwv ntxiv ntawm kev taw qhia. Kev siv nce, nqis, sab xis lossis sab laug tso cai hloov pauv ntawm cov xeev. Lub xeev tam sim no ib txwm yuav luam tawm ntawm kab thib ob ntawm LCD Zaub.
Kauj ruam 6: Stopwatch
Lub stopwatch yog qhov yooj yim heev. Thaum xub thawj, tus nqi timer yuav rov pib dua. Lub sijhawm tuaj yeem pib los ntawm kev siv khawm sab laug thiab toggled los ntawm kev siv sab laug thiab sab xis. Siv nce lossis nqis rov ua timer. Lub sijhawm tuaj yeem tuaj yeem teeb tsa rov qab rau xoom los ntawm kev siv khawm xaiv ob zaug - tawm hauv cov ntawv qhia zaub mov thiab nkag mus rau nws ib zaug ntxiv, raws li lub sijhawm yuav raug teem rau xoom los ntawm kev nkag mus rau lub tswb.
Kauj Ruam 7: Txee
Tsawg kawg, muaj lub txee siv. Nkag mus rau lub xeev txee rov pib dua lub txee. Nws tuaj yeem pib los ntawm kev siv ib lub pob nyem, tshwj tsis yog xaiv lub pob. Nws tau ua raws li qhov yooj yim nce/nqis txee, uas tus nqi tsis tuaj yeem me dua 0.
Kauj Ruam 8: Simulation
Kauj Ruam 9: Tau Piv Txwv
Koj tuaj yeem rub tawm IDE ntawm no: YAKINDU Statechart Cov Cuab Yeej
Thaum koj tau rub tawm IDE, koj pom qhov piv txwv ntawm File -> N ew -> Piv txwv
Nws siv dawb rau cov nyiam ua haujlwm, tab sis koj kuj tuaj yeem siv 30 hnub sim.
Pom zoo:
Yuav Ua Li Cas Tsis Siv Lub Qhov Rooj Tsis Tshua, Lub Cev Kub Lub Cev, GY-906, 433MHz Siv Arduino: 3 Kauj Ruam
Yuav Ua Li Cas Tsis Siv Lub Qhov Rooj Tsis Tuaj, Lub Cev Kub Lub Cev, GY-906, 433MHz Siv Arduino: Hnub no peb yuav ua lub qhov rooj tsis kov, nws yuav ntsuas koj lub cev kub. Hauv qhov xwm txheej tam sim no, Nws yog ib qho tseem ceeb heev uas yuav tsum paub yog tias ib tus neeg lub cev kub ntau dua li ib txwm, thaum ib tus neeg raug ncaws tawm
Arduino Otto Neeg Hlau Nrog Lub Xeev Tshuab: 4 Kauj Ruam
Arduino Otto Robot Nrog Lub Xeev Lub Tshuab: Txheej txheem cej luam Hauv qhov haujlwm no, kuv xav qhia koj txoj hauv kev ntawm txoj haujlwm ntawm Otto Robot, uas yog Arduino raws li DIY neeg hlau. Siv YAKINDU Statechart Cov Cuab Yeej (pub dawb rau qhov tsis yog kev lag luam) peb tuaj yeem siv lub xeev cov tshuab yooj yim los ua qauv tus cwj pwm
Lub Xeev Tshuab ntawm Arduino - Lub Teeb Pom Kev Mus Los: 6 Cov Kauj Ruam (nrog Duab)
Lub Xeev Tshuab ntawm Arduino - Lub Teeb Pom Kev Mus Los: Nyob zoo! Kuv yuav qhia koj yuav ua li cas teeb tsa txoj kev tsheb ciav hlau rau cov neeg taug kev rau Arduino hauv C ++ nrog lub xeev tsis siv lub tshuab los ntawm kev siv YAKINDU Xeev Cov Cuab Yeej. Qhov no yuav qhia txog lub zog ntawm cov tshuab hauv lub xeev thiab tuaj yeem siv ua tus qauv rau yav tom ntej
Digital Saib ntawm Arduino Siv Lub Xeev Lub Xeev Tshuab: 6 Cov Kauj Ruam
Digital Saib ntawm Arduino Siv Lub Xeev Lub Xeev Tshuab: Hav nyob ntawd, Kuv yuav qhia koj li cas lub moos saib tuaj yeem tsim nrog YAKINDU Lub Xeev Daim Ntawv Qhia Cuab Yeej thiab ua haujlwm ntawm Arduino, uas siv LCD Keypad Shield. saib tau los ntawm David Harel. Nws tau tshaj tawm cov ntawv abou
Lub Xeev Tshuab thiab Kev Ua Haujlwm Ntau Yam ntawm Arduino Nrog SPI Cov Nthuav Tawm: 3 Cov Kauj Ruam
Lub Xeev Lub Tshuab thiab Ua Haujlwm Ntau Yam ntawm Arduino Nrog SPI Cov Nthuav Tawm: Lub lim tiam dhau los, Kuv tau thov kom tsim cov txheej txheem los sim foob pob hluav taws nrog arduino. Nws xav tau txog 64 qhov kev tawm los tswj cov hluav taws. Ib txoj hauv kev ua nws yog siv IC nthuav dav. Yog li 2 cov kev daws teeb meem muaj:- I2C nthuav dav tab sis nws xav tau inverter thaum koj