Cov txheej txheem:

Rhythm Tes: 6 Kauj Ruam
Rhythm Tes: 6 Kauj Ruam

Video: Rhythm Tes: 6 Kauj Ruam

Video: Rhythm Tes: 6 Kauj Ruam
Video: Jennifer Lopez - On The Floor ft. Pitbull 2024, Kaum ib hlis
Anonim
Ntsuas Tes
Ntsuas Tes

Qhov cyberglove no yog hais txog kev ua kom raug raws lub sijhawm.

Lub teeb yuav los ntawm koj txhais caj npab (lub luj tshib) mus rau koj txhais tes thiab thaum lub teeb tuaj txog ntawm koj txhais tes koj yuav tsum nias koj cov ntiv tes ntawm lub mini photocell.

Yog tias koj nias koj txhais tes ntawm lub mini photocell ntawm lub sijhawm yog lub teeb tig ntsuab. Yog tsis yog, cov leds tig liab.

Kauj Ruam 1: Sau Cov Khoom

  • Hnab looj tes
  • Npuag kom cov hnab looj tes ntev dua
  • WS2812B LED sawb
  • Hlau
  • Arduino
  • Mini duab

Kauj Ruam 2: Ua Cov Hluav Taws Xob

Ua Circuit Court
Ua Circuit Court
Ua circuits
Ua circuits

Ua ntej txuas cov hlua coj mus rau arduino. Koj tuaj yeem ua qhov ntawd los ntawm kev txuas tus +5v rau 5v ntawm arduino. Din yuav tsum txuas nrog A0 ntawm arduino thiab GND yuav tsum txuas nrog GND ntawm arduino.

Koj kuj tseem yuav tsum txuas lub mini photocell mus rau arduino los ntawm kev txuas mus rau 5v xaim los ntawm cov hlua coj thiab los ntawm tib qhov chaw txuas nrog xaim rau PIN 6 ntawm arduino. Lwm sab los ntawm daim duab me me yuav tsum tau txuas nrog GND xaim los ntawm cov coj coj

Kauj Ruam 3: Tsim Hnab Hnab

Tsim Hnab Hnab
Tsim Hnab Hnab

Lub hnab looj tes yuav tsum muaj qhov loj me kom haum rau cov hlua coj. Cov leds yuav tsum tau ua ke kom ua rau muaj kev lom zem ntxiv rau saib.

Rau qhov kev ua si no koj yuav tsum tau siv koj txhais caj npab thiab koj xav kom tuaj yeem txav tau dawb. Qhov no tuaj yeem ua tiav los ntawm kev tso cov arduino ntawm lub hnab looj tes. Kuv siv velcro los ua tus khawm kom lo lo rau lub hnab looj tes. Tom qab ntawd txhawm rau txhim kho kev nyab xeeb ntxiv koj tuaj yeem tso hlua nyob ib ncig ntawm lub hnab looj tes thiab ib puag ncig ntawm arduino.

Mini photocell tau muab xaws rau hauv hnab looj tes yog li nws yuav nyob hauv qhov chaw.

Thaum kawg koj yuav tsum zais cov xov hlau kom nws zoo dua. Qhov ntawd tuaj yeem ua tiav nrog cov ntaub uas yuav xaws saum cov xov hlau.

Kauj ruam 4: Soldering

Soldering
Soldering

Tam sim no koj tuaj yeem ua cov kab txuas sib txuas los ntawm kab hluav taws xob ruaj ntseg los ntawm kev siv cov laug.

Kauj ruam 5: Coding

Coding
Coding
Coding
Coding
Coding
Coding

// Ib qho yooj yim niaj hnub NeoPixel strip xeem program.

// NEOPIXEL ZOO TSHAJ PLAWS rau kev ua haujlwm tau zoo tshaj plaws: // - Ntxiv 1000 uF CAPACITOR ntawm NeoPixel sawb tus + thiab - kev sib txuas. // - MINIMIZE WIRING LENGTH ntawm microcontroller board thiab thawj pixel. //-NeoPixel strip's DATA-IN yuav tsum dhau los ntawm 300-500 OHM RESISTOR. // - AVOID txuas NeoPixels ntawm LIVE CIRCUIT. Yog tias koj yuav tsum, ib txwm // txuas GROUND (-) ua ntej, tom qab ntawd +, tom qab ntawd cov ntaub ntawv. //-Thaum siv lub 3.3V microcontroller nrog 5V-powered NeoPixel strip, // LOGIC-LEVEL CONVERTER ntawm cov kab ntawv yog QHOV TSEEM CEEB. // (Hla cov no yuav ua haujlwm tau zoo ntawm koj lub workbench tab sis tuaj yeem ua tsis tiav hauv daim teb)

#include #ifdef _AVR_ #include // Yuav tsum tau rau 16 MHz Adafruit Trinket #endif

// Tus pin twg ntawm Arduino txuas nrog NeoPixels? // Ntawm Trinket lossis Gemma peb hais kom hloov qhov no mus rau 1: #define LED_PIN 6

// Muaj pes tsawg NeoPixels txuas rau Arduino? #define LED_COUNT 60

// Tshaj tawm peb NeoPixel strip object: Adafruit_NeoPixel strip (LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800); uint32_t xim = strip. Color (127, 127, 127); // Cov xim dawb, rau qhov pib bool clickedCorrectly = cuav; // Argument 1 = Tus lej pixels hauv NeoPixel strip // Argument 2 = Arduino tus lej tus lej (feem ntau siv tau) // Argument 3 = Pixel hom chij, ntxiv ua ke raws li xav tau: // NEO_KHZ800 800 KHz bitstream (feem ntau NeoPixel cov khoom w/ WS2812 LEDs) // NEO_KHZ400 400 KHz (classic 'v1' (tsis v2) FLORA pixels, WS2811 tsav tsheb) // NEO_GRB Pixels tau txuas rau GRB bitstream (feem ntau NeoPixel khoom) // NEO_RGB Pixels tau txuas rau RGB bitstream (v1 FLORA pixels, tsis yog v2) // NEO_RGBW Pixels tau txuas rau RGBW bitstream (NeoPixel RGBW cov khoom)

// teeb tsa () muaj nuj nqi-khiav ib zaug thaum pib --------------------------------

void teeb () {// Cov kab no tshwj xeeb los txhawb Adafruit Trinket 5V 16 MHz. // Lwm lub rooj tsavxwm, koj tuaj yeem tshem tawm ntu no (tab sis tsis muaj teeb meem tawm nws): #if txhais (_ AVR_ATtiny85_) && (F_CPU == 16000000) clock_prescale_set (clock_div_1); #endif // Xaus ntawm Trinket-tshwj xeeb cov cai.

pinMode (A0, INPUT); strip.begin (); // INITIALIZE NeoPixel strip object (REQUIRED) strip.show (); // Kaw tag nrho cov pixels ASAP strip.setBrightness (10); // Teeb ci rau li 1/5 (max = 255)}

// loop () muaj nuj nqi-sau ntau zaus tsuav lub rooj tsavxwm nyob ---------------

lub voj void () {clickedCorrectly = theatreChaseOne (xim); yog (clickedCorrectly) {xim = strip. Color (0, 255, 0); } lwm {xim = strip. Color (255, 0, 0); }}

// Qee lub luag haujlwm ntawm peb tus kheej rau kev tsim cov yeeb yaj kiab -----------------

// Theatre-marquee-style chasing teeb. Dhau xim (32-ntsis tus nqi, // a la strip. Color (r, g, b) raws li tau hais los saum no), thiab ncua sijhawm (hauv ms) // ntawm cov thav duab. bool theatreChaseOne (uint32_t xim) {bool raug = tsis tseeb; bool clickedWrong = tsis tseeb; rau (int index = 0; index 800) {// tus nqi lub teeb sensor yog (index <16) {// 2 leds ua ntej kawg ces koj tuaj yeem nyem xim = strip. Color (255, 0, 0); // xim liab leds clickedWrong = tseeb; // nyem tsis raug ces leds tig liab} lwm qhov yog (! clickedWrong) {// yog tias tsis yog xim tsis zoo = strip. Color (0, 255, 0); // ntsuab xim leds raug = tseeb; // nyem qhov raug ces leds tig ntsuab}} strip.clear (); strip.setPixelColor (17 - ntsuas, xim); // thawj kab coj teeb sawb.setPixelColor (18 + cim, xim); // kab thib ob coj teeb sawb.setPixelColor (53 - ntsuas, xim); // kab thib peb coj teeb sawb.show (); ncua (300); } rov qab raug; }

Kauj Ruam 6: Kev hloov pauv

Hloov
Hloov
Hloov
Hloov
Hloov
Hloov

Kuv tau hloov qee yam. Ua ntej kuv zais cov arduino yog li nws yuav yooj yim dua los siv "Rythm tes" thiab qhov thib ob kuv hloov txoj cai me ntsis. Kuv tau hloov txoj cai kom thaum koj nias lub sijhawm kom xim ntsuab thiab LEDS txav nrawm dua. Los ntawm kev ua li ntawd LED Swill dhau los 10% sai dua ua ntej. Qhov no ua rau qhov kev ua si nthuav dua

Nov yog li cas tam sim no:

// Ib qho yooj yim niaj hnub NeoPixel strip xeem program. // NEOPIXEL ZOO TSHAJ PLAWS rau kev ua haujlwm tau zoo tshaj plaws: // - Ntxiv 1000 uF CAPACITOR ntawm NeoPixel sawb tus + thiab - kev sib txuas. // - MINIMIZE WIRING LENGTH ntawm microcontroller board thiab thawj pixel. //-NeoPixel strip's DATA-IN yuav tsum dhau los ntawm 300-500 OHM RESISTOR. // - AVOID txuas NeoPixels ntawm LIVE CIRCUIT. Yog tias koj yuav tsum, ib txwm // txuas GROUND (-) ua ntej, tom qab ntawd +, tom qab ntawd cov ntaub ntawv. //-Thaum siv 3.3V microcontroller nrog 5V-powered NeoPixel sawb, // LOGIC-LEVEL CONVERTER ntawm cov kab ntawv yog QHOV RECOMMENDED. // (Hla cov no yuav ua haujlwm tau zoo ntawm koj lub rooj ua haujlwm tab sis tuaj yeem ua tsis tau hauv daim teb) #suav nrog #ifdef _AVR_ #include // Yuav tsum tau rau 16 MHz Adafruit Trinket #endif // Tus pin twg ntawm Arduino txuas nrog NeoPixels? // Ntawm Trinket lossis Gemma peb hais kom hloov qhov no mus rau 1: #define LED_PIN 6 // Muaj pes tsawg NeoPixels tau txuas rau Arduino? #define LED_COUNT 60 // Tshaj tawm peb NeoPixel strip object: Adafruit_NeoPixel strip (LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800); uint32_t xim = strip. Color (127, 127, 127); // Cov xim dawb, rau qhov pib bool clickedCorrectly = cuav; int index = 0; int luv = 300; int tau = 0; unsigned ntev yav dhau losMs = millis (); // Cov lus sib cav 1 = Tus lej pixels hauv NeoPixel strip // Argument 2 = Arduino tus lej tus lej (feem ntau siv tau) // Cov lus sib cav 3 = Pixel hom chij, ntxiv ua ke raws li xav tau: // NEO_KHZ800 800 KHz bitstream (feem ntau NeoPixel cov khoom w/ WS2812 LEDs) // NEO_KHZ400 400 KHz (classic 'v1' (tsis v2) FLORA pixels, WS2811 tsav tsheb) // NEO_GRB Pixels tau txuas rau GRB bitstream (feem ntau NeoPixel khoom) // NEO_RGB Pixels tau txuas rau RGB bitstream (v1 FLORA pixels, tsis yog v2) // NEO_RGBW Pixels tau xaim rau RGBW bitstream (NeoPixel RGBW cov khoom) // teeb tsa () muaj nuj nqi-khiav ib zaug thaum pib -------------------- ------------ tsis muaj teeb tsa () {// Cov kab no tshwj xeeb los txhawb Adafruit Trinket 5V 16 MHz. // Lwm lub rooj tsavxwm, koj tuaj yeem tshem tawm ntu no (tab sis tsis muaj teeb meem tawm nws): #if txhais (_ AVR_ATtiny85_) && (F_CPU == 16000000) clock_prescale_set (clock_div_1); #endif // Xaus ntawm Trinket-tshwj xeeb cov cai. Serial.begin (9600); thaum (! Serial) {; // tos rau qhov chaw nres nkoj txuas mus txuas. Xav tau rau ib txwm USB chaw nres nkoj nkaus xwb} pinMode (A0, INPUT); strip.begin (); // INITIALIZE NeoPixel strip object (REQUIRED) strip.show (); // Kaw tag nrho cov pixels ASAP strip.setBrightness (10); // Teeb tsa qhov kaj txog li 1/5 (max = 255)} // loop () muaj nuj nqi-ua haujlwm ntau dua tsuav lub rooj tsavxwm nyob ntawm --------------- tsis muaj dab tsi voj () {unsigned ntev currentMs = millis (); // Tau txais lub sijhawm tam sim no int tus nqi = analogRead (A0); // Nyeem qhov ntsuas lub teeb tam sim no yog (tus nqi> 900 && qhov tshwm sim == 0) {// Yog tias lub ntsuas hluav taws xob raug nias thiab tsis muaj qhov tshwm sim tau sau tseg tsis tau, ua rau pom qhov tshwm sim yog (ntsuas = ntu) {// Txheeb xyuas yog tias tam sim no voj tshaj qhov ncua sij hawm yav dhau losMs = currentMs; // Teeb lub ncua sijhawm tshiab rau lub sijhawm tam sim no + ntu ntsuas ntsuas + = 1; // Teeb lub leds ib kauj ruam ntxiv hauv lub voj yog (ntsuas> 17) {// Ua kom kawg ntawm lub voj tuav qhov ntsuas = 0; yog (qhov tshwm sim == 2) {// Ntawm qhov tshwm sim raug ncua = (int) max ((ncua * 0.95), 50); // Ceev los ntawm 10%, nqes mus rau 50ms luv/ xim = strip. Color (0, 255, 0); // Teeb cov coj mus rau ntsuab} lwm qhov yog (qhov tshwm sim == 1) {// Ntawm qhov ua tsis raug ncua nruab nrab = 300; // Pib dua lub sijhawm xim = strip. Color (255, 0, 0); // Teeb lub leds rau liab} lwm yam {// Tsis muaj qhov tshwm sim ntes xim = strip. Color (255, 0, 0); // Teeb cov leds rau liab} tshwm sim = 0; // Rov ua qhov tshwm sim rau lub hlis tom ntej} theatreChaseOne (xim, ntsuas); // Teeb lub leds rau zaub. }} // Qee qhov kev ua haujlwm ntawm peb tus kheej rau kev tsim cov teebmeem ua yeeb yam ----------------- // Theatre-marquee-style chasing teeb. Dhau xim (32-ntsis tus nqi, // a la strip. Color (r, g, b) raws li tau hais los saum no), thiab ncua sijhawm (hauv ms) // ntawm cov thav duab. void theatreChaseOne (uint32_t xim, int index) {strip.clear (); strip.setPixelColor (17 - ntsuas, xim); // thawj kab coj teeb sawb.setPixelColor (18 + cim, xim); // kab thib ob coj teeb sawb.setPixelColor (53 - ntsuas, xim); // kab thib peb coj teeb sawb.show (); }

Pom zoo: