Cov txheej txheem:

Arduino Lub Teeb Tsho Tsho: 9 Kauj Ruam
Arduino Lub Teeb Tsho Tsho: 9 Kauj Ruam

Video: Arduino Lub Teeb Tsho Tsho: 9 Kauj Ruam

Video: Arduino Lub Teeb Tsho Tsho: 9 Kauj Ruam
Video: Delocalization of Schrödinger eigenfunctions – Nalini Anantharaman – ICM2018 2024, Hlis ntuj nqeg
Anonim
Image
Image

Cov khaub ncaws hnav tsis zoo yog lub hauv paus ntawm cov hnub so. Txhua xyoo koj yuav tsum nce koj qhov kev ua si thiab hnav lub tsho zoo tshaj plaws uas koj tuaj yeem pom. Tab sis xyoo no koj tuaj yeem ua ib qho zoo dua thiab ua lub tsho tshaj plaws. Peb siv Adafruit Wearables los tsim lub tsho zoo nkauj zoo nkauj uas paub tseeb tias yuav txhawb koj cov phooj ywg thiab tsev neeg.

Adafruit tsim qee qhov haujlwm zoo nyob ib puag ncig Wearables twb yog li peb tau siv lawv cov cai hloov pauv los siv txoj haujlwm no los ntawm lawv txoj haujlwm Sparkle Skirt.

Hauv qhov kev qhia no koj yuav:

  • Kawm paub siv Wearables
  • Code koj li Flora lub rooj tsavxwm tseem ceeb, ntsuas kev ntsuas, thiab NeoPixels kom pom kev siv Arduino

Kauj ruam 1: Pib

Pib Pib
Pib Pib

Peb tab tom yuav siv Adafruit Flora Wearables, lub roj teeb pob, xov hluav taws xob, thiab lub tsho ntev hnub so. Koj tseem yuav xav tau qee cov xov tsis tu ncua, koob, thiab ntsia thawv ntsia hlau. Txhua yam yuav ua rau muaj kev nkag siab lub sijhawm. Peb cov ntawv yuav muab rau Santa kom pom kev tab sis peb txhawb txhua txoj kev ntseeg thiab hnub so thiab kev ntseeg, yog li muaj tswv yim!

  • Adafruit Flora Main Board (https://www.adafruit.com/product/659)
  • Flora Accelerometer (https://www.adafruit.com/product/1247)
  • Flora RGB NeoPixels (https://www.adafruit.com/product/1260)
  • Roj teeb Pob (https://www.adafruit.com/product/727)
  • Cov Ntawv Coj (https://www.adafruit.com/product/641)

Kauj ruam 2: Txheej txheem

Txheej txheem
Txheej txheem

Peb yuav tsum teeb tsa lub pixels, lub rooj tsavxwm tseem ceeb, thiab tus ntsuas ntsuas ua ntej pib txheej txheem kev xaws. Cov pixels yuav muaj cov ntaub ntawv sib txuas, + rau lub zog, thiab - rau hauv av. Tus ntsuas hluav taws xob xav tau kev sib txuas rau 3V, SCL, SDA, thiab hauv av.

Teeb tsa lub pixels, lub rooj tsavxwm tseem ceeb, thiab ntsuas lub ntsuas ntawm lub tsho loj thaum koj npaj yuav xaws nws. Nco ntsoov tias koj yuav tsis hla ib qho kev sib dhos vim qhov ntawd yuav ua rau luv. Txij li thaum peb muaj peb lub ntsej muag pawg thawj coj hauv thiab NeoPixels ntsej muag tawm peb tau siv 3V, Pin 9, thiab Hauv av los txuas NeoPixels.

NeoPixels muaj tus xub uas qhia tias yuav ua li cas cov ntaub ntawv txuas mus los ntawm Flora lub rooj tsav xwm tseem ceeb mus rau NeoPixel tom ntej. Ua kom ntseeg tau tias txhua NeoPixels tau sib dhos ua ke ib yam nkaus.

Kauj Ruam 3: Cov Lus Qhia Ntxiv

Qhov tseem ceeb ntawm kev xaws yog peb yam; tsis muaj luv/hla txoj hlua, nruj pob ntseg thaum xaus txoj hlua, thiab kev sib txuas zoo rau Wearables.

Tsis muaj luv/Plooj Hla

Nco ntsoov teeb tsa koj cov Wearables kom koj cov xaws yuav tsis hla. Cov kab yuav tsum tsis txhob hla, pom tseeb. Thaum koj muaj tus txheej txheem uas ua kom txhua qhov kev sib dhos sib cais, koj yuav tsum paub tseeb tias thaum koj xaws nws nruj. Yog tias koj tso qis heev nws tuaj yeem tso cai rau xov kom kov. Thaum koj ua tiav txoj hlua txiav qhov xaus ntau dhau yog li tsis muaj cov xov uas ploj lawm.

Tight Knots

Thaum xaus txoj hlua plooj, ib txoj hlua nruj yuav ua kom cov hlua tsis xoob. Qhov ua kom yuam kev yog tso me me dollop ntawm cov ntsia thawv ntsia hlau ntsia rau ntawm lub hauv caug thiab cia nws qhuav. Qhov no pab tuav lub hauv caug, zoo ib yam li kua nplaum. Cov xov hluav taws xob tsis tuav zoo ib yam hauv txoj hlua li cov xov li niaj zaus yog li kuv pom zoo kom siv cov ntsia thawv ntsia hlau lossis koj tuaj yeem cua tuaj nrog xaws los xoob.

Kev Sib Txuas Zoo

Xyuas kom cov loops ntawm cov pins nruj. Qhov no yuav pab xyuas kom meej tias yog tias koj lub Circuit tsis ua haujlwm, peb paub tias nws tsis yog kev sib txuas uas yog teeb meem. Koj tuaj yeem hla lub koob 2-3 zaug kom ntseeg tau tias yuav muaj kev sib txuas zoo ib txwm.

Tswv yim/Tricks

Nco ntsoov tias koj cov khoom ntawm cov khaub ncaws tsis muaj zog thaum koj coj nws tawm thiab tawm. Qhov no yog txoj hauv kev yooj yim tshaj plaws kom muaj xov kov thiab ua rau luv. Tsis txhob qhib koj lub roj teeb kom txog thaum cov khoom ntawm cov khaub ncaws tau yooj yim.

Kauj Ruam 4: Txhim Kho Cov Cheebtsam

Stitching Cheebtsam
Stitching Cheebtsam
Stitching Cheebtsam
Stitching Cheebtsam

Thawj daim uas peb xav tau txuas yog Flora Main Board. Plooj lub rooj tsavxwm rau koj lub tsho khuam siv xov tsis tu ncua los ntawm ob tus pin koj tsis tau npaj yuav siv. Qhov no yuav tuav lub rooj tsavxwm nyob hauv qhov chaw thiab ua kom yooj yim dua los xaws siv cov xov hluav taws xob. Ob peb lub voj yooj yim txaus kom nws tsis txhob txav mus.

Tom ntej no, koj yuav tsum txuas plaub qhov kev sib txuas los ntawm Flora Main Board thiab Accelerometer. Qhov no yuav yog Lub Hwj Chim, Hauv Paus, SCL, thiab SDA. Yog tias koj tso Accelerometer mus rau sab saud sab laug ntawm lub rooj tsavxwm tseem ceeb cov kev sib txuas yuav ncaj ncaj. Yog li koj yuav muaj plaub txoj hlua sib cais txhawm rau txuas ob lub laug cam. Siv me ntsis cov ntsia thawv ntsia hlau rau ntawm ob lub pob qhov kawg kom lawv tsis txhob tawg. Ib qho ntsia hlau me me ntawm cov laug cam yuav tsis ua rau lawv mob.

Thaum kawg, koj yuav tsum txuas 3V, hauv av, thiab cov ntaub ntawv sib txuas los ntawm Flora Main board mus rau NeoPixels. Koj tuaj yeem ua ob qhov ntev, txuas txuas ntxiv rau hauv av thiab lub zog txij li cov ntawd yog hauv qab thiab sab saum toj ntawm NeoPixels. Txog cov ntaub ntawv sib txuas los ntawm Pin 9 koj yuav tsum tau ua qhov sib cais ntawm txhua NeoPixel mus rau tom ntej.

Kauj Ruam 5: Arduino IDE

Pawg Thawj Tswj Hwm Flora yog Arduino-sib xws yog li peb yuav siv Arduino IDE rau peb cov cai. Koj tuaj yeem rub tawm qhov hloov tshiab kawg los ntawm qhov txuas no.

Kuj tseem muaj lub vev xaib los ntawm qhov txuas no.

Muaj plaub lub tsev qiv ntawv uas xav tau ntxiv los siv peb NeoPixels thiab Accelerometer. Mus rau Sketch, suav nrog lub tsev qiv ntawv, Tswj cov tsev qiv ntawv. Rau txhua tus koj yuav tsum tshawb nrhiav nws los ntawm lub npe, xaiv qhov tseeb version, thiab nyem rau nruab.

  • Adafruit NeoPixel
  • Adafruit Unified Sensor
  • Adafruit TSL 2561
  • Adafruit LSM303DLHC Cov

Thaum cov no raug teeb tsa thiab kev ua tiav tiav peb tau npaj los sim peb lub tsho loj kom paub tseeb tias txhua yam ua haujlwm.

Kauj Ruam 6: Kuaj Cov Ntawv

Xeem Ntawv
Xeem Ntawv

Txhawm rau sim peb txoj haujlwm peb yuav tsum txuas peb Adafruit lub rooj tsav xwm tseem ceeb rau koj lub khoos phis tawj siv USB cable. Tom qab ntawd mus rau Cov Cuab Yeej, Chaw Nres Nkoj, thiab xaiv koj li Flora Main board hauv cov npe.

Thawj qhov peb yuav sim yog tias lub ntsuas cua ua haujlwm tau zoo. Mus rau Cov Ntaub Ntawv, Piv Txwv, Adafruit LSM303DLHC, ua kom nrawm dua. Qhov no yuav qhib ib tsab ntawv uas ntsuas yog tias lub ntsuas tau txuas nrog thiab nyeem cov haujlwm sib koom. Tshaj tawm rau koj lub rooj tsavxwm thiab qhib Serial Monitor nyob rau sab xis saum toj ntawm Arduino IDE. Yog tias koj pom qhov tseem ceeb hloov pauv hauv Serial Monitor, zoo li hauv daim duab, thaum txav lub ntsuas hluav taws xob ces nws ua haujlwm!

Qhov thib ob uas peb yuav sim yog tias NeoPixels ua haujlwm. Mus rau Cov Ntaub Ntawv, Piv Txwv, Adafruit NeoPixels, strandtest. Ua ntej peb sau tsab ntawv no, hloov tus Pin rau 9 thiab tus lej pixels mus rau 6 (lossis ib qho twg koj tab tom siv rau koj txoj haujlwm). Tshaj tawm rau koj lub rooj tsavxwm thiab yog tias txhua lub pixels teeb pom kev koj tau npaj rau tsab ntawv kawg!

Kauj Ruam 7: Tsab Ntawv Kawg

Tsab ntawv kawg
Tsab ntawv kawg

Tam sim no nws yog lub sijhawm los thauj peb cov lej kawg. Luam cov cai hauv qab no rau hauv cov ntaub ntawv ua haujlwm tshiab. Tus Pin tau teeb tsa rau 9 thiab tus lej NeoPixels tau teeb tsa rau 6. Yog tias koj siv qee yam sib txawv, hloov cov ntawd ua ntej yuav khiav tsab ntawv no. Koj tuaj yeem kho cov xim nyiam los ntawm kev kho qhov tseem ceeb ntawm R, G, & B los ntawm 0-255. Koj kuj tseem tuaj yeem ntxiv cov xim nyiam los ntawm kev ntxiv kab tshiab. Qhov txav chaw pib tuaj yeem hloov kho ib yam nkaus. Tus lej qis dua, nws yooj yim dua yog txhawm rau txheeb xyuas qhov txav thiab tig rau NeoPixels. Thaum koj ua qhov kev hloov pauv uas koj xav tau, txuag thiab muab tso rau hauv koj lub Rooj Tswjhwm Saib Xyuas Flora Main Board. Koj yuav tsum tuaj yeem pom cov pixels teeb pom kev zoo yog tias koj txav lub ntsuas qhov ntsuas ib puag ncig. Thaum koj pom tias koj tuaj yeem tshem tawm ntawm koj lub khoos phis tawj thiab peb tuaj yeem txuas rau peb lub roj teeb pob.

#include #include #include #include #define PIN 9 #define PIXELCOUNT 6 // Parameter 1 = tus lej pixels hauv kab txaij // Parameter 2 = tus lej tus lej (feem ntau zoo tab sis peb siv 9) // Parameter 3 = hom pixel chij, ntxiv ua ke raws li xav tau: // NEO_RGB Pixels tau txuas rau RGB bitstream (v1 FLORA pixels, tsis v2) // NEO_GRB Pixels tau txuas rau GRB bitstream (feem ntau NeoPixel cov khoom lag luam peb siv) // NEO_KHZ400 400 KHz (classic 'v1' (tsis yog v2) FLORA pixels, WS2811 tsav tsheb) // NEO_KHZ800 800 KHz bitstream (feem ntau cov khoom NeoPixel w/WS2812 LEDs. cov khoom peb siv) Adafruit_NeoPixel strip = Adafruit_NeoPixel (PIXELCOUNT, PIN, NEO_GRB + NEO_KHZ800); Adafruit_LSM303_Accel_Unified accel = Adafruit_LSM303_Accel_Unified (54321); // Kho R, G, B ntawm 0-255 thiab // ntxiv tshiab {nnn, nnn, nnn}, rau ntau xim // RGB uint8_t myFavoriteColors [3] = {{ 255, 255, 255}, // dawb {255, 0, 0}, // liab {0, 255, 0}, // ntsuab}; // tsis txhob hloov kab hauv qab no #fine FAVCOLORS sizeof (myFavoriteColors) /3 // tus lej no hloov kho qhov nkag siab yooj yim // tus lej qis dua = nkag siab ntau #define MOVE_THRESHOLD 5 // super rhiab heev tam sim no tsis muaj teeb tsa () {Serial.begin (9600); // Sim pib ua ntej thiab ceeb toom yog tias peb tsis tuaj yeem pom lub nti // Siv Serial Monitor los saib cov ntawv luam tawm yog (! Accel.begin ()) {Serial.println ("Peb tau txais teeb meem. Nws yog koj, tsis yog kuv … Tsis tuaj yeem pib ua LSM303. Kuv yuav pib nrog kev txheeb xyuas sai ntawm cov thaiv "); thaum (1); } strip.begin (); strip.show (); // Teeb pixels rau 'tawm'} void loop () {/ * Tau txais qhov xwm txheej tshiab sensor */ sensors_event_t kev tshwm sim; accel.getEvent (& kev tshwm sim); // Serial.print ("Accel X:"); Serial.print (event.acceleration.x); Serial.print (""); // Serial.print ("Y:"); Serial.print (event.acceleration.y); Serial.print (""); // Serial.print ("Z:"); Serial.print (event.acceleration.z); Serial.print (""); // Tau txais qhov loj (ntev) ntawm 3 axis vector ob npaug khaws ciaVector = event.acceleration.x*event.acceleration.x; khaws Vector += event.acceleration.y*event.acceleration.y; khaws Vector += event.acceleration.z*event.acceleration.z; khaws Vector = sqrt (khaws cia Vector); // Serial.print ("Len:"); Serial.println (khaws Vector); // tos qeeb me ntsis (250); // tau txais cov ntaub ntawv tshiab! accel.getEvent (& kev tshwm sim); ob npaug newVector = event.acceleration.x*event.acceleration.x; newVector += event.acceleration.y*event.acceleration.y; newVector += event.acceleration.z*event.acceleration.z; newVector = sqrt (newVector); // Serial.print ("New Len:"); Serial.println (tshiab Vector); // peb puas tau txav mus? yog (abs (newVector - khawsVector)> MOVE_THRESHOLD) {Serial.println ("Flashy! Flash! eeb! flash! McFlash!"); flashRandom (10, 2); // thawj tus lej yog 'tos' ncua, luv luv == luv dua twinkle flashRandom (10, 4); // tus lej thib ob yog pes tsawg neopixels los ua ib txhij teeb flashRandom (10, 6); }} tsis muaj dab tsi flashRandom (tos tos, uint8_t ntau npaum li cas) {rau (uint16_t kuv = 0; kuv <ua li cas; i ++) {// tau xaiv los ntawm cov xim nyiam int c = random (FAVCOLORS); int dawb = myFavoriteColors [c] [0]; int liab = myFavoriteColors [c] [1]; int ntsuab = myFavoriteColors [c] [2]; // cov pixels qhib rau hauv qhov kev txiav txim rau (int i = 0; i <6; i ++) int j = strip.numPixels (); Serial.print ("Pixel rau"); Serial.println (kuv); // tam sim no peb yuav 'ploj' nws hauv 3 kauj ruam rau (int x = 0; x = 0; x--) {int w = dawb * x; w /= 3; int r = liab * x; r /= 3; int g = ntsuab * x; g /= 3; strip.setPixelColor (i, strip. Color (w, r, g)); strip.show (); ncua (tos); }} // LEDs yuav tawm thaum ua tiav (lawv ploj mus rau 0)}

Kauj Ruam 8: Roj Teeb Pob

Roj Teeb Pob
Roj Teeb Pob

Txhawm rau khaws koj lub tsho luv luv txuas ntxiv txuas ntxiv peb yuav siv lub roj teeb pob. Peb yuav tsum ua kom muaj hlua khi rau pob kom nws tsis txhob dai ntawm lub rooj tsavxwm. Kuv siv lub ces kaum ntawm lub hauv ncoo qub ua kuv lub hnab roj teeb. Kuv kaw qhov qhib sab thiab txuas ib sab ntawm sab saum toj mus rau lub tsho loj kom txaus rau ntawm lub rooj tsavxwm loj uas nws tuaj yeem ntsaws tau yooj yim thiab tsis rub rau nws.

Plug lub roj teeb pob rau hauv lub rooj tsavxwm tseem ceeb, tig qhov hloov me me ntawm lub rooj tsavxwm tseem ceeb los ntawm qhov qhib rau, thiab qhib koj lub roj teeb pob. Tam sim no koj lub tsho loj yuav tsum ua haujlwm thiab npaj hnav.

Kauj Ruam 9: Xaus

Xaus
Xaus

Tam sim no koj tau ua lub teeb tsho loj uas yuav ua rau txhua tus phooj ywg thiab tsev neeg nyiam koj! Tab sis qhov no tsis yog txoj haujlwm hnub so xwb. Ua kom koj tus valentine lub plawv lub tsho sov lub tsho lossis teeb lub tsho shamrock rau St. Patrick Hnub. Siv koj lub tswv yim thiab qhia rau peb paub tias koj tau tsim dab tsi!

Pom zoo: