Cov txheej txheem:

Capacitive Touch Mood/Ambilight: 8 Kauj Ruam
Capacitive Touch Mood/Ambilight: 8 Kauj Ruam

Video: Capacitive Touch Mood/Ambilight: 8 Kauj Ruam

Video: Capacitive Touch Mood/Ambilight: 8 Kauj Ruam
Video: Selfmade ambilight + Tutorial NO FLICKERING LIGHT (all HDMI/AV+RaspberryPi2+Fushicai+Hyperion) 2024, Lub Xya hli ntuj
Anonim
Capacitive Touch Mood/Ambilight
Capacitive Touch Mood/Ambilight

Cov lus qhia no yog sau sai ntawm kuv qhov kev paub tsim lub ntsej muag ua haujlwm ntau yam. Qee qhov kev paub pib ntawm hluav taws xob hluav taws xob xav tau. Txoj haujlwm tseem tsis tau tiav, qee qhov ntxiv kev ua haujlwm thiab tweaking yuav tsum tau ua tab sis nws twb tau ua haujlwm lawm. Yog tias koj hais mav txaus siab txog cov lus qhia no kuv yuav hloov kho tshiab. Nws lub plawv ntawm cov kab ke yog Arduino. Nws yuav ua cov txheej txheem los ntawm USB lossis txhua qhov Capacitive kov cov tswv yim thiab tswj lub teeb RGB. Cov lus qhia no tau muab faib ua peb ntu:- Ntu ntu kov tau npog lub qhov muag tsis pom cov nyees khawm- Qhov kev xav ntawm lub ntsej muag npog kev tswj hwm lub teeb pom kev zoo- Ntu qhov tsis pom kev npog cov tswv yim los ntawm cov chaw nres nkoj, ua RGB qhov tsim los ntawm lub khoos phis tawj tswj hwm lub teeb. Disclaimer: Cov khoom siv hluav taws xob tuaj yeem ua rau txaus ntshai, koj tus kheej yog lub luag haujlwm rau kev puas tsuaj uas tau ua. Qee cov cai tau sau los ntawm cov rooj sib tham thiab tej zaum yuav tsis muaj lub npe ntawm nws tus tswv. Thov qhia rau kuv paub thiab kuv yuav ntxiv koj lub npe.

Kauj Ruam 1: Daim Ntawv Teev Npe

Cov khoom siv hauv qab no xav tau rau cov lus qhia no:- Arduino+USB cable- Breadboard- Khoos phis tawj fais fab mov- 3x RGB strips, txheeb xyuas dealextreme.com.- 3x TIP120 FETs, zoo li https://uk.farnell.com/stmicroelectronics/tip120 /darlington-transistor-to-220/dp/9804005- Ib pawg resistors (6 * 10 kiloOhm, 3 * 2 megaOhm)-Cov xov hlau ntau heev. - Cov cuab yeej Capacitive kov- Cov nplhaib hlau rau hauv av- Hlau tooj liab lossis phaj- Ib yam dab tsi los tsim nws rau hauv (zoo li lub txee rau khoom:)

Kauj Ruam 2: Capacitive Touch - Basics & Circuit

Capacitive Touch - Pib & Circuit
Capacitive Touch - Pib & Circuit
Capacitive Touch - Pib & Circuit
Capacitive Touch - Pib & Circuit
Capacitive Touch - Pib & Circuit
Capacitive Touch - Pib & Circuit

Txij li thaum kuv tau pleev xim rau kuv lub txee rau khoom, Kuv muaj txoj hauv kev los 'hloov kho' lawv ib yam. Kuv xav tswj lub teeb pom kev zoo los ntawm kev kov tsis pom. Thaum xub thawj, kuv txoj kev npaj yuav siv IC tshwj xeeb rau qhov no (zoo li Atmel QT240). Tab sis tom qab ntawd kuv dawm taw ntawm nplooj ntawv piav qhia tias Arduino tuaj yeem ua raws lub peev xwm ntsuas los ntawm software. Qhov hluav taws xob hluav taws xob tuaj yeem pom hauv daim duab, lub ntsuas hluav taws xob yog cov xaim tooj liab xaim (tsuas yog ib qho qhia rau qhov yooj yim). Kev rhiab heev yog tswj los ntawm cov resistors pom ua ntej txhua tus pin. Lawv tuaj yeem suav txij ntawm 1 MegaOhm (kov tsis pub dhau) txog 40 MegaOhm (12-24 ntiv tawm) nyob ntawm seb puas xav tau lossis ze rau kev kov (Kuv tau siv 2M Ohm resistors). Kev sim nrog qhov muaj txiaj ntsig kom txog thaum lub ntsuas coj zoo li qhov xav tau. Nws yog lub tswv yim zoo los teeb tsa qee qhov kev coj ua (cais los ntawm daim nyias nyias uas tsis ua) ua txuas nrog cov kab hluav taws xob hauv av tom qab ntawm txhua txoj hlua. Txoj kev no cov ntsuas yuav ruaj khov dua thiab tsis muaj kev cuam tshuam los ntawm lub suab nrov. Ntau cov duab hais txog kev teeb tsa lub ntsuas hluav taws xob hauv cov phau ntawv. Ib lub ntsaws tau teeb tsa ib yam kom yooj yim txuas nrog lub Circuit Court tom qab. Filler tau siv los zais txhua yam, thiab tom qab ntawd lawv tau npaj los pleev xim.

Kauj Ruam 3: Capacitive Touch - Code & Testing

Capacitive Touch - Code & Xeem
Capacitive Touch - Code & Xeem

Cov hauv paus hauv qab no tuaj yeem siv ntawm Arduino rau kev debugging, txheeb xyuas qhov muaj txiaj ntsig nrog arduino cov saib txuas. Rau qhov tseem ceeb tau tsim. Thawj yog ntsuas qhov ua tau zoo ntawm qhov system. Qhov thib ob txog rau thib rau yog qhov kev nkag siab zoo ntawm txhua tus pin. Qhov tseem ceeb yuav tsum nce thaum nyob ze koj tus ntiv tes. Yog tsis yog, txheeb xyuas qhov kev sib txuas tsis zoo thiab cuam tshuam. Tus nqi tiv thaiv tuaj yeem hloov pauv los txiav txim siab rhiab heev. Los ntawm kev ua ib qho qauv-yog tom qab uas tau qhib rau ntawm qee qhov kev nkag siab, tuaj yeem hloov tau. Qhov no yuav raug siv hauv qhov kawg arduino code. Kev paub ntau ntxiv, qhia kom nyeem: https://www.arduino.cc/playground/Main/CapSense--- Arduino CapTouch Debugging Code ---#suav nrog qhov tsis muaj teeb tsa () {CapSense cs_2_3 = CapSense (2, 4); // 10M resistor ntawm tus pin 2 & 4, tus pin 4 yog tus pin sensor, ntxiv xaim, ntawv ciCapSense cs_2_4 = CapSense (2, 7); // 10M resistor ntawm tus pin 2 & 7, tus pin 7 yog tus pin sensor, ntxiv xaim, ntawv ciCapSense cs_2_5 = CapSense (2, 8); // 10M resistor ntawm tus pin 2 & 8, tus pin 8 yog tus pin sensor, ntxiv xaim, ntawv ciCapSense cs_2_6 = CapSense (2, 12); // 10M resistor ntawm tus pin 2 & 12, tus pin 12 yog tus pin sensor, ntxiv xaim, ntawv ciCapSense cs_2_7 = CapSense (2, 13); // 10M resistor ntawm tus pin 2 & 13, tus pin 13 yog tus pin sensor, ntxiv xaim, foilvoid teeb () {Serial.begin (9600);} void loop () {ntev pib = millis (); ntev total1 = cs_2_3.capSense (30); ntev tag2 = cs_2_4.capSense (30); ntev tag nrho 3 = cs_2_5.capSense (30); ntev tag nrho 4 = cs_2_6.capSense (30); ntev tag nrho 5 = cs_2_7.capSense (30); Serial.print (millis () - pib); // txheeb xyuas qhov ua tau zoo hauv milliseconds Serial.print ("\ t"); // tab cim rau debug windown spacing Serial.print (total1); // print sensor output 1 Serial.print ("\ t"); Serial.print (total2); // luam tawm cov zis 2 Serial.print ("\ t"); Serial.print (tag nrho 3); // print sensor output 3 Serial.print ("\ t"); Serial.print (tag nrho 4); // luam tawm cov zis 4 Serial.print ("\ t"); Serial.println (tag nrho 5); // luam tawm cov zis tawm 5 ncua (10); // kev xav qeeb kom txwv cov ntaub ntawv mus rau chaw nres nkoj txuas} --- END ---

Kauj Ruam 4: Lub Teeb Mood - Lub hauv paus & Circuit

Mood Light - Pib & Circuit
Mood Light - Pib & Circuit
Mood Light - Pib & Circuit
Mood Light - Pib & Circuit
Mood Light - Pib & Circuit
Mood Light - Pib & Circuit

Tam sim no nws yog lub sijhawm los tsim ib feem ntawm qhov system. Arduino's PWM pins yuav siv los tswj txhua xim. PWM txhais tau tias Pulse Width Modulation, los ntawm kev hloov tus pin rau thiab tawm nrawm heev leds yuav dim ntawm 0 txog 255. Txhua tus pin yuav ua kom nrov dua los ntawm FET. Txog tam sim no, cov kab ke tsuas muaj ib txoj kab rau ib xim, txhais tau tias txhua RGB kab ntawv yuav raug tswj ib zaug thiab xav tau 3 PWM pins (ib qho rau txhua xim). Yav tom ntej kuv xav kom muaj peev xwm tswj tau txhua ntawm kuv plaub RGB kab txaij. Qhov ntawd txhais tau tias 4*3 = 12 PWM pins (thiab tej zaum yog Arduino Mega). Ok, sijhawm rau qee qhov kev qhia! Qhov no (saib daim duab) yog lub hauv paus sawv cev ntawm Circuit (yuav ua kom zoo dua sai sai). Lub peev xwm ntsuas tau suav nrog ib yam (ib feem ntsuab). Yeej muaj peb ntu uas yuav tsum tau piav qhia:- FETThis yog lub tshuab raj kuv tau tham txog. Nws muaj Lub Rooj Vag, Qhov Chaw thiab Cov Dej. Nws ua kom lub siab me me tam sim no ntawm lub qhov rooj (txuas nrog Arduino) thiab qhib txoj hauv kev rau RGB sawb uas tau tsav ntawm 12 volts. Qhov chaw yuav tsum yog ntawm +12V, ntws ntawm GND (Hauv av). Txheeb xyuas daim ntawv tshwj xeeb ntawm koj li FET rau qhov pinout tseeb. Txhua RGB channel yuav tsum tau muab tso ua ntej nws tus kheej FET. Hauv qhov kev nkag siab no, nws tau ua zoo li Arduino tswj kev hloov. Lub ntsiab lus, tias cov xov hlau sib txuas yuav tsum txuas nrog +12V thiab qhov tam sim no tau poob los ntawm txhua qhov sib cais xim. Cov hlua tau suav nrog cov neeg tawm tsam, yog li tsis muaj kev txhawj xeeb txog qhov ntawd! Peb lwm tus yuav txwv qhov siab tshaj tam sim no FET yuav ntws. Sab saum toj peb tus tiv thaiv twb tau nyob hauv RGB strip. I soldered USB cables rau RGB strips yog li kuv tuaj yeem hloov kho tau yooj yim. Cov ntsaws los ntawm lub hub qub tau muab tso rau ntawm kuv lub khob cij. Siv lub khoos phis tawj qub qub siv hluav taws xob rau kua txiv, 12V rau siv lub zog RGB sawb thiab thaum kawg 5V rau lub Circuit yog tias koj xav kom nws khiav yam tsis muaj USB cable.

Kauj Ruam 5: Mood Light - Code & Control

Lub teeb pom kev zoo yog tswj los ntawm lub peev xwm ntsuas. Txog tam sim no, Kuv tsuas yog teeb tsa cov ntsuas ntsuas 2 & 3 rau kev hloov xim. Lwm cov sensors tseem tsis tau ua haujlwm zoo txog tam sim no. Nov yog tus lej: --- Arduino Mood Control Code ---#suav nrog const boolean invert = tseeb; const ntev timeout = 10000; // Capacitive sensor tshaj tawm CapSense In1 = CapSense (2, 4); // 2M resistor ntawm tus pin 4 & 2, tus pin 2 yog tus pin sensor, ntxiv xaim, ntawv ciCapSense In2 = CapSense (2, 7); // 2M resistor ntawm tus pin 4 & 6, tus pin 6 yog tus pin sensor, ntxiv xaim, ntawv ciCapSense In3 = CapSense (2, 8); // 2M resistor ntawm tus pin 4 & 8, tus pin 8 yog tus pin sensor, ntxiv xaim, ntawv ciCapSense In4 = CapSense (2, 12); // 2M resistor ntawm tus pin 4 & 8, tus pin 8 yog tus pin sensor, ntxiv xaim, ntawv ciCapSense In5 = CapSense (2, 13); // 2M resistor ntawm tus pin 4 & 8, tus pin 8 yog tus pin sensor, ntxiv xaim, ntawv ci // PWM Pin tshaj tawm hauv PinR1 = 3; int PinG1 = 5; int PinB1 = 6; // Lwm yam kev hloov pauv xim 1 = 128; // pib ntawm liab zoo li xim Brightness1 = 255; // pib ntawm qhov ci ntsa iab tag nrho RedValue1, GreenValue1, BlueValue1; // Lub RGB Cheeb Tsam tsis muaj teeb tsa () {// teeb tsa lub sijhawm ntsuas qhov tseem ceeb In1.set_CS_AutocaL_Millis (sij hawm dhau); In2.set_CS_AutocaL_Millis (sij hawm dhau); In3.set_CS_AutocaL_Millis (sij hawm dhau); In4.set_CS_AutocaL_Millis (sij hawm dhau); In5.set_CS_AutocaL_Millis (sij hawm dhau);} lub voj void () {ntev pib = millis (); ntev total1 = In1.capSense (30); ntev tag2 = In2.capSense (30); ntev tag nrho 3 = In3.capSense (30); ntev tag nrho4 = In4.capSense (30); ntev tag nrho 5 = In5.capSense (30); yog (total2> 150) {Xim 1 ++; // nce xim yog tias (Color1> 255) {// Color1 = 0; }} lwm tus yog (total3> 200) {Color1--; // txo cov xim yog tias (Xim 1 <0) {// Xim 1 = 255; } // hloov hue rau rgb hueToRGB (Color1, Brightness1); // sau xim rau PWM pins analogWrite (PinR1, RedValue1); analogWrite (PinG1, GreenValue1); analogWrite (PinB1, BlueValue1);} // muaj nuj nqi los hloov xim rau nws cov xim liab, Ntsuab, thiab Xiav. unsigned int ntu = scaledHue / 256; // ntu 0 txog 5 nyob ib puag ncig cov xim log tsis tau kos npe rau hauv segmentOffset = scaledHue - (ntu * 256); // txoj haujlwm nyob hauv ntu tsis tau kos npe rau kev qhuas = 0; unsigned int prev = (ci ntsa iab * (255 - segmentOffset)) / 256; unsigned int tom ntej = (ci ntsa iab * segmentOffset) / 256; yog (invert) {ci ntsa iab = 255-ci ntsa iab; kev qhuas = 255; ua ntej = 255-ua ntej; tom ntej = 255-tom ntej; } hloov (ntu) {rooj plaub 0: // liab RedValue1 = ci ntsa iab; GreenValue1 = tom ntej; BlueValue1 = qhuas; tawg; rooj plaub 1: // daj RedValue1 = ua ntej; GreenValue1 = ci ntsa iab; BlueValue1 = qhuas; tawg; rooj plaub 2: // ntsuab RedValue1 = qhuas; GreenValue1 = ci ntsa iab; BlueValue1 = tom ntej; tawg; rooj plaub 3: // cyan RedValue1 = qhuas; GreenValue1 = ua ntej; BlueValue1 = ci ntsa iab; tawg; rooj plaub 4: // xiav RedValue1 = tom ntej; GreenValue1 = qhuas; BlueValue1 = ci ntsa iab; tawg; rooj plaub 5: // magenta default: RedValue1 = ci ntsa iab; GreenValue1 = qhuas; BlueValue1 = ua ntej; tawg; }} --- KAWG ---

Kauj Ruam 6: Ambi Teeb - Arduino Sab

Tau kawg, nws yuav txias tag nrho kom tuaj yeem tswj lub teeb pom kev zoo los ntawm koj lub khoos phis tawj. Piv txwv los tsim kom pom kev kaj nrig lossis suab tswj lub suab disco. Tshooj lus no tsom mus rau ib puag ncig qhov pom kev, yav tom ntej kuv yuav ntxiv kev ua haujlwm zoo. Yog, tsis muaj qhov txuas ntxiv vim tias nws muaj nyob hauv Arduino. Qhov peb yuav siv yog qhov muaj peev xwm sib txuas lus sib txuas thiab qee qhov 'Ua Haujlwm 1.0' software. Hook-up koj arduino rau koj lub computer los ntawm USB cable (yog tias koj tau rub cov duab kos rau nws, nws twb yog). Txog rau arduino, zoo yuav tsum tau ntxiv qee cov cai ntxiv rau kev sib txuas lus txuas. Txoj cai yuav hloov mus mloog hom, tig ntawm lub peev xwm ntsuas tau tsuav nws tau txais RGB qhov tseem ceeb los ntawm lub khoos phis tawj. Tom qab ntawd nws teeb tus nqi RGB rau PWM tus pin. Nov yog kuv tus lej kawg rau tam sim no, txheeb xyuas qhov kev hloov pauv koj tus kheej: --- Arduino Ambilight Code ---#suav nrog const boolean invert = tseeb; const ntev timeout = 10000; ntev commStart = 0; char val; // Capacitive sensor tshaj tawmCapSense Hauv 1 = CapSense (2, 4); // 2M resistor ntawm tus pin 4 & 2, tus pin 2 yog tus pin sensor, ntxiv xaim, ntawv ciCapSense In2 = CapSense (2, 7); // 2M resistor ntawm tus pin 4 & 6, tus pin 6 yog tus pin sensor, ntxiv xaim, ntawv ciCapSense In3 = CapSense (2, 8); // 2M resistor ntawm tus pin 4 & 8, tus pin 8 yog tus pin sensor, ntxiv xaim, ntawv ciCapSense In4 = CapSense (2, 12); // 2M resistor ntawm tus pin 4 & 8, tus pin 8 yog tus pin sensor, ntxiv xaim, ntawv ciCapSense In5 = CapSense (2, 13); // 2M resistor ntawm tus pin 4 & 8, tus pin 8 yog tus pin sensor, ntxiv xaim, ntawv ci // PWM Pin tshaj tawm hauv PinR1 = 3; int PinG1 = 5; int PinB1 = 6; // Lwm yam kev hloov pauv xim 1 = 128; // pib ntawm liab zoo li xim Brightness1 = 255; // pib ntawm qhov ci ntsa iab tag nrho RedValue1, GreenValue1, BlueValue1; // Lub RGB Cheeb Tsam tsis muaj teeb tsa () {Serial.begin (9600); // pib kev sib txuas lus sib txuas // teeb tsa lub sijhawm ntsuas qhov tseem ceeb In1.set_CS_AutocaL_Millis (sij hawm dhau); In2.set_CS_AutocaL_Millis (sij hawm dhau); In3.set_CS_AutocaL_Millis (sij hawm dhau); In4.set_CS_AutocaL_Millis (sij hawm dhau); In5.set_CS_AutocaL_Millis (sij hawm dhau);} lub voj void () {ntev pib = millis (); ntev total1 = In1.capSense (30); ntev tag2 = In2.capSense (30); ntev tag nrho 3 = In3.capSense (30); ntev tag nrho4 = In4.capSense (30); ntev tag nrho 5 = In5.capSense (30); yog (Serial.available ()) {// Yog tias cov ntaub ntawv muaj rau nyeem, val = Serial.read (); // nyeem nws thiab khaws nws hauv val commStart = millis (); yog (val == 'S') {// Yog tias pib char tau txais, thaum (! Serial.available ()) {} // Tos kom txog rau tom ntej tus nqi. RedValue1 = Serial.read (); // Thaum muaj, muab. thaum (! Serial.available ()) {} // Zoo ib yam li saum toj no. GreenValue1 = Serial.read (); thaum (! Serial.available ()) {} BlueValue1 = Serial.read (); } Serial.print (RedValue1); Serial.print (GreenValue1); Serial.println (BlueValue1); } lwm yog ((millis () - commStart)> 1000) {yog (total2> 150) {Color1 ++; // nce xim yog tias (Color1> 255) {// Color1 = 0; }} lwm tus yog (total3> 200) {Color1--; // txo cov xim yog tias (Xim 1 <0) {// Xim 1 = 255; }} hueToRGB (Color1, Brightness1); } analogWrite (PinR1, RedValue1); analogWrite (PinG1, GreenValue1); analogWrite (PinB1, BlueValue1);} // muaj nuj nqi los hloov xim rau nws cov xim liab, Ntsuab, thiab Xiav. unsigned int ntu = scaledHue / 256; // ntu 0 txog 5 ib puag ncig cov xim log tsis tau kos npe rau ntu seffOffset = scaledHue - (ntu * 256); // txoj haujlwm nyob hauv ntu tsis tau kos npe rau kev qhuas = 0; unsigned int prev = (ci ntsa iab * (255 - segmentOffset)) / 256; unsigned int tom ntej = (ci ntsa iab * segmentOffset) / 256; yog (invert) {ci ntsa iab = 255-ci ntsa iab; kev qhuas = 255; ua ntej = 255-ua ntej; tom ntej = 255-tom ntej; } hloov (ntu) {rooj plaub 0: // liab RedValue1 = ci ntsa iab; GreenValue1 = tom ntej; BlueValue1 = qhuas; tawg; rooj plaub 1: // daj RedValue1 = ua ntej; GreenValue1 = ci ntsa iab; BlueValue1 = qhuas; tawg; rooj plaub 2: // ntsuab RedValue1 = qhuas; GreenValue1 = ci ntsa iab; BlueValue1 = tom ntej; tawg; rooj plaub 3: // cyan RedValue1 = qhuas; GreenValue1 = ua ntej; BlueValue1 = ci ntsa iab; tawg; rooj plaub 4: // xiav RedValue1 = tom ntej; GreenValue1 = qhuas; BlueValue1 = ci ntsa iab; tawg; rooj plaub 5: // magenta default: RedValue1 = ci ntsa iab; GreenValue1 = qhuas; BlueValue1 = ua ntej; tawg; }} --- KAWG ---

Kauj Ruam 7: Ambi Teeb - Sab Computer

Ntawm sab ntawm lub khoos phis tawj Kev Ua Haujlwm 1.0 kos duab tau ua tiav, saib processing.org. Qhov kev pab me me no (me ntsis tsis zoo) xam cov xim nruab nrab ntawm txhua lub sijhawm thiab xa qhov no mus rau qhov chaw nres nkoj. Nws yog qhov yooj yim heev tseem tsis tau muaj thiab nws tuaj yeem siv qee qhov tweaking, tab sis nws ua haujlwm tau zoo heev! Kuv yuav hloov kho nws yav tom ntej rau ntau qhov sib cais RGB kab txaij thiab ntu ntu. Koj kuj tseem tuaj yeem ua koj tus kheej, cov lus yooj yim heev. Nov yog tus lej: --- Ua 1.0 Code --- ntshuam ua tiav.serial.*; Ntshuam java.awt. AWTException; ntshuam java.awt. Robot; ntshuam java.awt. Rectangle; ntshuam java.awt.image. BufferedImage,); //size(screen.width, screen.height); // Luam cov npe ntawm cov chaw nres nkoj txuas, rau lub hom phiaj debugging: println (Serial.list ()); // Kuv paub tias thawj qhov chaw nres nkoj hauv daim ntawv teev npe ntawm kuv mac // ib txwm yog kuv li FTDI adapter, yog li kuv qhib Serial.list () [0]. // Ntawm lub tshuab Windows, qhov no feem ntau qhib COM1. // Qhib qhov chaw nres nkoj twg yog qhov koj tab tom siv. Txoj hlua portName = Serial.list () [0]; myPort = Serial tshiab (qhov no, portName, 9600);} kos tsis muaj dabtsis () {// duab (screenShot, 0, 0, dav, siab); screenShot = getScreen (); xim kleur = xim (0, 0, 0); kleur = xim (screenShot); //myPort.write(int(red(kleur))++, '+int (ntsuab (kleur))+', '+int (xiav (kleur))+13); //myPort.write(int(red(kleur))); //myPort.write (','); //myPort.write(int(green(kleur))); //myPort.write (','); //myPort.write(int(blue(kleur))); //myPort.write(13); sau (kleur); rect (30, 20, 55, 55);} xim xim (PImage img) {int cols = (img.width); int kab = (img.height); int dimension = (img.width*img.height); int ib = 0; tus g = 0; int ib = 0; img.loadPixels (); // Ga elke pixel langs (dimension) for (int i = 0; i <(dimension/2); i ++) {r = r+((img.pixels >> 16) &) 0xFF); g = g + ((img.pixels >> 8) & 0xFF); b = b + (img.pixels & 0xFF);} int mean_r = r/(dimension/2); int mean_g = g/(dimension/2); int mean_b = b/(dimension/2); xim mean_clr = xim (mean_r, mean_g, mean_b); myPort.write ('S'); myPort.write (mean_r); myPort.write (mean_g); myPort.write (mean_b); return (mean_clr);} PImage getScreen () {GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment (); GraphicsDevice gs = ge.getScreenDevices (); DisplayMode hom = gs [0].getDisplayMode (); Cov duab plaub ib puag ncig = Cov duab plaub tshiab (0, 0, hom.getWidth (), hom.getHeight ()); BufferedImage desktop = BufferedImage tshiab (hom.getWidth (), hom.getHeight (), BufferedImage. TYPE_INT_RGB); sim {desktop = Neeg Hlau tshiab (gs [0]). createScreenCapture (ciam teb); } ntes (AWTException e) {System.err.println ("Kev ntes lub vijtsam ua tsis tiav."); } rov qab (PImage tshiab (desktop));} --- END ---

Kauj Ruam 8: Qhov tshwm sim

Qhov tshwm sim
Qhov tshwm sim
Qhov tshwm sim
Qhov tshwm sim

Thiab qhov no yog qhov tshwm sim, nws yog qhov tseeb hauv qab ntawm kuv lub txaj. Kuv tseem xav tau hloov daim ntaub, nws yuav nthuav lub teeb ntau dua. Ntau cov duab ntawm qhov sai sai no Kuv vam tias koj nyiam cov lus qhia no thiab kuv tseem vam tias nws yog lub hauv paus rau koj tus kheej kev muaj tswv yim. Vim yog lub sijhawm txwv kuv tau sau nws sai heev. Koj yuav xav tau qee qhov kev paub txog arduino/electronics kom nkag siab nws tab sis kuv npaj yuav hloov kho yav tom ntej yog tias nws tau txais zoo.

Pom zoo: