Cov txheej txheem:
- Khoom siv
- Kauj ruam 1: Format SD Card
- Kauj Ruam 2: Npaj Arduino
- Kauj ruam 3: Arduino Sketch
- Kauj Ruam 4: Siv Txoj Haujlwm no
Video: Arduino TFT Drawing Program: 4 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:25
Cov lus qhia no qhia meej cov cai uas nkag mus rau hauv kev kos duab rau Arduino TFT screen. Txoj haujlwm no tshwj xeeb, txawm li cas los xij, vim nws tso cai rau kev txuag cov duab kos rau SD daim npav thiab thauj nws tom qab los kho ntau ntxiv!
Khoom siv
- Arduino Uno - thawj lossis yog clone sib xws
- TFT touchscreen - Kuv siv lub vijtsam Elegoo, txhais tau tias kuv xav tau Elegoo cov tsav tsheb.
- Micro SD nyeem ntawv pawg - siv los khaws cov ntaub ntawv teeb duab rau SD daim npav. Kuv lub vijtsam tau tsim los nyeem hauv qab cov zaub.
- Stylus - kuv lub vijtsam tuaj nrog ib qho. Ntiv tes ua haujlwm zoo ib yam nkaus.
- Micro SD daim npav - tsis pub ntau tshaj 32GB, vim exFAT kev txwv kev txwv (Arduino tuaj yeem nyeem FAT32 cov ntawv teev npe tab sis tsis exFAT. Feem ntau daim npav loj tau ua nrog exFAT.) Nov yog yam uas koj yuav muab tso rau hauv lub xov tooj nrog nthuav dav cia.
- Khoos phis tawj nrog Arduino IDE
- Programming cable - USB A rau USB B. Kuv Arduino tuaj nrog ib qho.
- SD daim npav adapter - siv los hloov Micro SD daim npav rau hauv ib qho SD tso rau hauv daim npav SD LOSSIS ib qho uas txuas daim npav SD mus rau USB qhov.
Kauj ruam 1: Format SD Card
- Nqa daim Micro SD daim ntawv thiab txuas nws rau koj lub khoos phis tawj siv koj daim npav SD daim npav
- Qhib File Explorer thiab nrhiav daim npav SD.
- Right-click nws thiab xaiv Hom ntawv.
- Teem cov kev xaiv raws li lub screenshot.
- Nyem Pib
- Ncua daim npav thaum tus txheej txheem tiav.
Yog tias koj tsis siv lub Windows, sim siv SD Formatter los ntawm SD koom haum.
Kauj Ruam 2: Npaj Arduino
- Nias koj lub vijtsam tiv thaiv mus rau Arduino, ua tib zoo saib kab kab.
- Ntxig daim npav SD rau hauv tus nyeem ntawv hauv qab lub vijtsam.
Kauj ruam 3: Arduino Sketch
Txawm hais tias daim ntawv teev npe tau yooj yim zoo nkauj, muaj ib tuj ntawm cov cai. Kuv yuav hla nws ib qib zuj zus ntawm no.
#suav nrog
#include #include #include #include
Elegoo_GFX, _TFTLCD, thiab TouchScreen yog txhua yam khoom siv tshwj xeeb. Yog tias koj siv lub vijtsam sib txawv, siv cov khw muag khoom muab cov tsev qiv ntawv.
SPI thiab SD tau siv los sib txuas lus nrog SD daim npav. SPI yog cov txheej txheem siv los ntawm SD daim npav tswj hwm.
#if txhais (_ SAM3X8E _) #undef _FlashStringHelper:: F (string_literal) #define F (string_literal) string_literal #endif
Qhov no kuj yog kho vajtse tshwj xeeb.
#define YP A3 // yuav tsum yog tus pin analog #txhais XM A2 // yuav tsum yog tus pin analog #define YM 9 #define XP 8
// Kov Rau Tshiab ILI9341 TP
#define TS_MINX 120 #define TS_MAXX 900 #define TS_MINY 70 #define TS_MAXY 920
#Txhais CSPIN 10
#txhais LCD_CS A3
#define LCD_CD A2 #define LCD_WR A1 #define LCD_RD A0 #define LCD_RESET A4
Txhua ntawm cov lus #define ua rau IDE hloov lub npe nrog tus nqi. Ntawm no, lawv teeb LCD thiab SD I/O pins.
// Muab cov npe rau qee qhov 16-ntsis xim qhov tseem ceeb: #define BLACK 0x0000 #define WHITE 0xFFFF #define RED 0xF800 #define BLUE 0x001F #define GREEN 0x07E0
Nov yog qee qhov xim siv hauv txoj cai. #txhais-ua lawv ua rau nyeem cov cai yooj yim dua.
#define PENRADIUS 3
Qhov no piav qhia qhov loj ntawm tus cwj mem kos duab.
#define MINPRESSURE 10#txhais MAXPRESSURE 1000
// Kom zoo dua qhov ntsuas qhov tseeb, peb yuav tsum paub qhov ua haujlwm
// nruab nrab ntawm X+ thiab X- Siv ib lub multimeter los nyeem nws // Rau qhov kuv tab tom siv, nws 300 ohms hla X phaj TouchScreen ts = TouchScreen (XP, YP, XM, YM, 300);
Elegoo_TFTLCD tft (LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
Cov lus no piav qhia qhov siab xav tau los sau npe kov, pib ua haujlwm kov, thiab pib lub vijtsam.
Cov ntaub ntawv cia; int storageSize; int stoX = 1; int stoY = 1;
Cov no yog qhov hloov pauv rau qhov khaws cia ntawm qhov program.
teeb tsa tsis muaj dab tsi (tsis muaj dab tsi) {Serial.begin (9600); Serial.println ("Xim program");
tft.reset ();
uint16_t tus cim = tft.readID ();
yog (tus cim == 0x0101) {tus cim = 0x9341; Serial.println (F ("Pom 0x9341 LCD tsav tsheb")); }
// Pib qhov screen
tft.begin (tus cim); tft.setRotation (2);
pinMode (13, NTAWV);
// Pib SD daim npav
yog (! SD.begin (CSPIN)) {Serial.println ("SD pib ua tsis tau tejyam"); rov qab; } Serial.println ("SD pib ua ntej");
// Kos rau keeb kwm yav dhau
drawBackground (); }
Lub teeb ua haujlwm pib Serial yog tias nws muaj, rov pib dua lub vijtsam, kuaj pom tus neeg tsav tsheb TFT, pib lub vijtsam, pib daim npav, thiab hu ua haujlwm los kos keeb kwm yav dhau.
Kuv yuav hla mus rau qhov tseem ceeb ntawm lub voj kev ua haujlwm. Txhua yam ntxiv tsuas yog siv los tsav lub vijtsam kov.
// Tshawb xyuas lub vijtsam nias thiab khaws nws rau qhov hloov pauv yog (p.z> MINPRESSURE && p.z <MAXPRESSURE) {// Nplai p.x = daim ntawv qhia (p.x, TS_MINX, TS_MAXX, tft.width (), 0); p.y = (tft.height () - map (p.y, TS_MINY, TS_MAXY, tft.height (), 0));
// Kos duab
yog (p.y> 21) {// Txuag cov ntaub ntawv rau SD daim npav cia = SD.open ("storage.txt", FILE_WRITE); storage.print (p.x); storage.print (","); storage.println (p.y); cia.close ();
// Dot ntawm txoj haujlwm kov
tft.fillCircle (p.x, p.y, PENRADIUS, WHITE); }
// Rho tawm khawm
yog ((p.y 198) && (p.x <219)) {deleteStorage (); }
// Thauj khawm ua
yog ((p.y 219)) {loadStorage (); }}
Yog tias pom xov xwm, teeb tsa qhov txawv ntawm qhov chaw ntawm xovxwm.
Tom qab ntawd, yog tias cov xovxwm nyob hauv thaj chaw teeb duab, khaws cov ntsiab lus rau SD daim npav hauv kev khaws cia.txt thiab kos lub voj voog ntawm qhov chaw nias, nrog rau qhov loj me thiab xim.
Tom qab ntawd, yog tias qhov xovxwm nyob ntawm qhov chaw ntawm lub pob rho tawm, khiav lub luag haujlwm uas tshem tawm cov duab khaws tseg. Yog tias koj siv lub vijtsam loj sib txawv, sim ua si nrog lub pob qhov chaw qhov tseem ceeb.
Tom qab ntawd, yog tias qhov xovxwm nyob ntawm qhov chaw khawm khawm, khiav lub luag haujlwm uas thauj cov duab khaws cia. Yog tias koj siv lub vijtsam loj sib txawv, sim ua si nrog lub pob qhov chaw qhov tseem ceeb.
Tam sim no, kuv yuav piav qhia lub luag haujlwm.
Thawj qhov haujlwm yog hu ua teeb tsa kos keeb kwm yav dhau thiab cov nyees khawm.
void drawBackground () {// Teeb tom qab tft.fillScreen (BLACK);
// Xim ntawv
tft.setTextColor (WHITE); tft.setTextSize (3); tft.setCursor (0, 0); tft.println ("Xim");
// Load khawm
tft.fillRect (219, 0, 21, 21, GREEN);
// Ntshiab khawm
tft.fillRect (198, 0, 21, 21, RED); }
Nws ua rau lub vijtsam dub, sau lo lus Xim, thiab kos cov duab plaub fab rau cov nyees khawm. Yog tias koj siv lub vijtsam loj sib txawv, sim ua si nrog khawm qhov chaw qhov tseem ceeb.
void deleteStorage () {// Rho tawm cov ntawv SD.remove ("storage.txt");
// Teem keeb kwm yav dhau
tft.fillScreen (BLACK);
// Rho tawm cov ntawv ua tiav
tft.setTextColor (WHITE); tft.setTextSize (2); tft.setCursor (0, 0); tft.println ("storage.txt deleted");
// Cia tus neeg siv nyeem nws
ncua (2000);
// Kos duab ntxiv
drawBackground (); }
Kev tshem tawm cov haujlwm tshem tawm cov ntaub ntawv khaws cia.txt, ua rau lub vijtsam dub, thiab muab cov lus ua tiav rau kev tshem tawm. Tom qab ntawd nws hu rau drawBackground ua haujlwm kom tso cai rau koj pib pleev xim lwm yam.
void loadStorage () {// Tsis txhob rov ua dua los ntawm cov ntiv tes qeeb (250);
// Txheeb xyuas cov ntaub ntawv khaws cia
yog (! SD.exists ("storage.txt")) {Serial.println ("Tsis muaj cov ntaub ntawv khaws cia.txt"); rov qab; }
// Qhib cov ntawv hauv hom nyeem nkaus xwb
cia = SD.open ("storage.txt", FILE_READ);
// Thaum muaj cov ntaub ntawv, thaum (stoY> 0) {// Hloov kho txoj haujlwm hloov pauv stoX = storage.parseInt (); stoY = storage.parseInt ();
// Kos los ntawm kev cia
tft.fillCircle (stoX, stoY, PENRADIUS, WHITE); } // Kaw cov ntaub ntawv cia.close (); }
Thaum kawg, lub luag haujlwm loadStorage tshawb xyuas cov ntaub ntawv khaws cia, qhib nws hauv hom nyeem nkaus xwb, tom qab ntawd rov ua dua lub voj no:
Tsuav yog muaj cov ntaub ntawv ntau ntxiv,
- Hloov kho txoj haujlwm hloov pauv nrog cov ntaub ntawv txheeb cais los ntawm storage.txt
- Kos ib lub voj voog ntawm qhov chaw thau khoom
Thaum lub voj ua tiav thiab tsis muaj cov ntaub ntawv ntxiv, nws kaw cov ntaub ntawv khaws cia.
Cov cai rau daim duab no tuaj yeem pom hauv qab no. Tsuas yog rub nws, qhib nws hauv Arduino, thiab xa nws mus rau koj lub rooj tsavxwm!
Kauj Ruam 4: Siv Txoj Haujlwm no
Tsuas yog ntsaws rau hauv koj Arduino rau lub zog siv hluav taws xob - khoos phis tawj, roj teeb, phab ntsa wart, thiab lwm yam thiab pib teeb duab. Txhawm rau lwv koj daim duab thiab nws cov ntaub ntawv khaws tseg, nias lub pob liab. Txhawm rau rub daim duab los ntawm kev khaws cia thiab ua haujlwm txuas ntxiv rau nws, nyem lub pob ntsuab. Txoj hauv kev no, koj tuaj yeem rov ua ntau zaus ntawm daim duab!
Raws li kev txuas ntxiv, sim npaj cov duab hauv koj lub computer:
- Txuas daim npav SD nrog cov ntaub ntawv rau hauv koj lub computer.
- Qhib cia.txt hauv koj cov ntawv nyiam/tus lej hloov kho.
- Luam tag nrho cov txiaj ntsig hauv storage.txt.
- Ua raws qhov txuas no mus rau qhov phiaj xwm phiaj xwm phiaj xwm.
- Rho tawm ob qhov piv txwv piv txwv ntawm sab laug.
- Muab koj cov ntaub ntawv tso rau qhov piv txwv cov ntsiab lus.
Nov yog txoj hauv kev zoo los qhia tawm koj cov duab kos - tej zaum txawm tias sim hloov qhov xim ntawm Arduino lossis hauv cov ntsiab lus -phiaj xwm!
Kev hloov kho tau txais tos, thiab kuv xav pom qee cov lus qhia hauv cov lus. Ua tsaug rau qhov saib ntawm no thiab kuv vam tias koj yuav pom kev siv zoo rau nws hauv koj tus kheej cov haujlwm!
Pom zoo:
Mini Drawing Bot - Live Android App - Trignomentry: 18 Kauj Ruam (nrog Duab)
Mini Drawing Bot-Live Android App-Trignomentry: Ua tsaug rau Vajtswv thiab koj txhua tus uas ua rau kuv qhov project Baby-MIT-Cheetah-Robot yeej thawj qhov khoom plig hauv kev sib tw Ua kom nws txav mus. Kuv zoo siab heev vim tias ntau tus phooj ywg nug ntau cov lus nug hauv kev sib tham thiab hauv cov lus. Ib ntawm cov lus nug tseem ceeb yog yuav ua li cas
Bluetooth LED Drawing Board thiab IOS App: 9 Kauj Ruam (nrog Duab)
Bluetooth LED Drawing Board thiab IOS App: Hauv qhov kev qhia no, koj yuav tuaj yeem tsim Bluetooth LED board uas tuaj yeem kos duab los ntawm iPhone app peb tsim. Hauv daim ntawv thov no, cov neeg siv yuav tuaj yeem tsim Kev Sib Txuas 4 game uas tseem yuav tshwm rau ntawm daim gameboard no. Qhov no yuav yog ch
DIY MINI CNC DRAWING TSHUAB: 6 Kauj Ruam
DIY MINI CNC DRAWING TSHUAB: Qhov no yog lub tshuab me me cnc
Yuav Ua Li Cas Lub Sijhawm Teev Sijhawm Siv Arduino thiab TFT Zaub - Arduino Mega RTC Nrog 3.5 Ntiag TFT Zaub: 4 Kauj Ruam
Yuav Ua Li Cas Lub Sijhawm Teev Sijhawm Siv Arduino thiab TFT Zaub | Arduino Mega RTC Nrog 3.5 Ntiag TFT Zaub: Mus Saib Kuv Youtube Channel.Introduction:- Hauv kab ntawv no kuv yuav ua "Sijhawm Sijhawm" siv 3.5 nti TFT kov LCD, Arduino Mega 2560 thiab DS3231 RTC module…. Ua ntej pib… tshawb xyuas cov vis dis aus los ntawm kuv tus YouTube channel..Ntau:- Yog tias koj siv Arduin
Arduino CNC Drawing Machine (lossis Txoj Kev Kom Ua Tau Zoo): 10 Kauj Ruam (nrog Duab)
Arduino CNC Drawing Machine (lossis Txoj Kev Kom Ua Tau Zoo): Txoj haujlwm no yog ua los ntawm cov khoom feem ntau uas yooj yim mus nrhiav. Lub tswv yim yog siv ob lub tshuab computer uas tsis siv thiab muab sib dhos los tsim lub tshuab siv tshuab uas zoo ib yam li tshuab CNC. Cov khoom siv tawm ntawm cov tsav suav nrog mo