Cov txheej txheem:

Arduino MusicStump: Teeb, Kov Kov thiab Buzzer: 3 Kauj Ruam
Arduino MusicStump: Teeb, Kov Kov thiab Buzzer: 3 Kauj Ruam

Video: Arduino MusicStump: Teeb, Kov Kov thiab Buzzer: 3 Kauj Ruam

Video: Arduino MusicStump: Teeb, Kov Kov thiab Buzzer: 3 Kauj Ruam
Video: Stomp Shield for Arduino 2024, Hlis ntuj nqeg
Anonim
Arduino MusicStump: Lub Teeb, Kov Kov thiab Buzzer
Arduino MusicStump: Lub Teeb, Kov Kov thiab Buzzer

Cov ntoo sib cuam tshuam nrog lub nplhaib LED nyob rau sab saum toj, lub suab nrov kom ua suab thiab lub ntsej muag kov lub ntsej muag sab hauv uas hloov xim thaum koj kov nws. Txhawm rau ua qhov kev lom zem me ntsis koj yuav xav tau cov hauv qab no:

Khoom siv hluav taws xob:- 1x Arduino Uno

- 15x kab

- 1x soldering hlau nrog puag ncig

- 1x Adafruit 8-qhov tseem ceeb raug kaw (CAP1188)

- 1x Arduino fais fab cable

- 1x8 LED ntiv nplhaib

- 1 x Buzzer

- 1x kub kua nplaum phom

-Rub lub tsev qiv ntawv ntawm CAP1188

- Rub lub tsev qiv ntawv ntawm Adafruit Neopixel

Ntxiv (casing):

- 1x ntoo stump

- 1x stick rau sab hauv

- Ntoo platter tso nws txhua qhov/hauv

- Cov tsiaj ntim khoom rau sab nraum zoov

Koj tseem tuaj yeem siv lwm yam li sab nrauv, muaj tswv yim!

Tam sim no cia pib …

Kauj Ruam 1: Kauj Ruam 1: LED Ntiv Nplhaib Nrog Kev Kaw

Kauj Ruam 1: LED Ntiv Nplhaib Nrog Kev Ruaj Ntseg
Kauj Ruam 1: LED Ntiv Nplhaib Nrog Kev Ruaj Ntseg

Tam sim no yog tias koj muaj hmoo koj lub nplhaib LED twb muaj pins txuas rau nws. Yog tsis yog nws yog lub sijhawm kom yaj!

Yam uas peb yuav siv rau txoj haujlwm no yog:

- DI (Cov tswv yim digital, tus pin 6 ~

- 5V (rau lub zog, 5V tus pin)

- GND (Hauv av, GND tus pin)

Qhov ntawd yog lub nplhaib LED rau tam sim no.

Muab nws tso rau hauv lub khob cij thiab txuas txhua yam raws li hauv qab no: SDA/MISO hauv tus pin (analog hauv) A4SCK hauv tus pin (analog hauv) A5VIN hauv (fais fab) 5VGND hauv GND pin1x cable ntawm C1 (ntawm Kev kov nws tus kheej)

Tam sim no sim ntsuas upload cov cai hauv qab no rau koj Arduino:

// Julia Emmink // Lub teeb thiab kov tus lej rau tsob ntoo sib tham sib 19 /// Ua los ntawm kev siv Adafruit Neopixel thiab Adafruit cov neeg raug kaw (CAP1188) (yuav tsum tau teeb tsa) thiab LED ntsais muag yam tsis muaj ncua

// NEOPIXEL ~~~~~~~~~~~~~~~~~~

#suav nrog

#define PIXELSPIN 6 // Qhov twg koj txuas nrog LED Ntiv Nplhaib

#define NUMPIXELS 8 // Qhov ntau ntawm LEDs uas nyob ntawm koj lub nplhaib #define CALIBRATIONTIME 20000

Adafruit_NeoPixel pixels = Adafruit_NeoPixel (NUMPIXELS, PIXELSPIN, NEO_GRB + NEO_KHZ800);

unsigned ntev pixelsInterval = 500; // lub sijhawm peb yuav tsum tau tos

unsigned ntev colorWipePreviousMillis = 0; unsigned ntev theatreChasePreviousMillis = 0; unsigned ntev zaj sawvPreviousMillis = 0; tsis kos npe ntev rainbowCyclesPreviousMillis = 0;

int theatreChaseQ = 0;

uint16_t currentPixel = 0; // dab tsi pixel peb tab tom ua haujlwm

// KUV ~~~~~~~~~~~~~~~~~~~~~~~~

#include #include #include

// Pib dua Pin yog siv rau I2C lossis SPI

#define CAP1188_RESET 9

// CS pin tau siv rau software lossis kho vajtse SPI

#define CAP1188_CS 10

// Cov no tau hais tseg rau software SPI, rau kho vajtse SPI, txheeb xyuas koj

// board's SPI pins hauv Arduino cov ntaub ntawv #define CAP1188_MOSI 11 #define CAP1188_MISO 12 #define CAP1188_CLK 13

// Siv I2C, tsis muaj tus pin rov pib dua!

Adafruit_CAP1188 cap = Adafruit_CAP1188 ();

void teeb tsa () {

// NEOPIXEL ~~~~~~~~~~~~~~~~~~ currentPixel = 0; pixels.begin (); // Qhov no pib ua lub tsev qiv ntawv NeoPixel. pixels.show (); // Qhov no xa qhov hloov tshiab pixel xim rau kho vajtse.

// KUV ~~~~~~~~~~~~~~~~~~~~~~~~

Serial.begin (300); Serial.println ("CAP1188 xeem!");

yog (! cap.begin ()) {

Serial.println ("CAP1188 tsis pom"); thaum (1); } Serial.println ("CAP1188 pom!"); }

void voj () {

// KOV + NEOPIXEL ~~~~~~~~~~~~~~~~~~~~~ uint8_t kov = cap.touched (); yog (kov == 0) {yog ((tsis tau kos npe ntev) (millis () - colorWipePreviousMillis)> = pixelsInterval) {colorWipePreviousMillis = millis (); colorWipe (pixels. Color (0, 255, 125)); }} lwm {yog ((tsis tau kos npe ntev) (millis () - colorWipePreviousMillis)> = pixelsInterval) {colorWipePreviousMillis = millis (); colorWipe (pixels. Color (100, 0, 150)); }}

}

void colorWipe (uint32_t c) {

// NEOPIXEL ~~~~~~~~~~~~~~~~~~ // Tshem tawm cov xim pixels.setPixelColor (currentPixel, c); pixels.setPixelColor (currentPixel - 1, pixels. Color (0, 0, 0)); pixels.show (); currentPixel ++; yog (currentPixel == NUMPIXELS) {currentPixel = 0; pixels.setPixelColor (7, pixels. Color (0, 0, 0));

}

}

Kuaj nws thiab muaj kev lom zem! Raws li koj pom thaum koj kov C1 qaum xim hloov. (Yog tias nws tsis yog thawj zaug tsuas yog ntsaws koj Arduino thiab ntsaws nws rov qab rau hauv koj lub computer.)

Kauj Ruam 2: Kauj Ruam 2: Ntxiv Suab

Nrog kev siv cov ntawv qhia yooj yim Kuv tau ua qhov no. Cov lus qhia hauv qab no:

github.com/xitangg/-Pirates-of-the-Caribbe…

Lub sijhawm los tuav koj lub suab nrov! Muab tus (-) ntawm lub suab nrov hauv ib qho ntawm GND pins thiab (+) hauv tus pin 10 ~

Qhov ntawd yog txog nws, tam sim no lub sijhawm los khiav txoj cai dua thiab hnov tias Pirates of Caribbean qhib nkauj zoo nkauj! Tam sim no muaj kev lom zem sim!

// Julia Emmink // Lub teeb, kov thiab suab paj nruag code rau tsob ntoo sib tham sib 2018-01-19 // Ua nrog kev siv Adafruit Neopixel thiab Captive Touch (CAP1188) (yog yuav tsum tau teeb tsa) thiab LED ntsais muag yam tsis muaj ncua

// NEOPIXEL ~~~~~~~~~~~~~~~~~~#suav nrog

#define PIXELSPIN 6

#define NUMPIXELS 8 #define CALIBRATIONTIME 20000

Adafruit_NeoPixel pixels = Adafruit_NeoPixel (NUMPIXELS, PIXELSPIN, NEO_GRB + NEO_KHZ800);

unsigned ntev pixelsInterval = 500; // lub sijhawm peb yuav tsum tau tos

unsigned ntev colorWipePreviousMillis = 0; unsigned ntev theatreChasePreviousMillis = 0; unsigned ntev zaj sawvPreviousMillis = 0; tsis kos npe ntev rainbowCyclesPreviousMillis = 0;

int theatreChaseQ = 0;

uint16_t currentPixel = 0; // dab tsi pixel peb tab tom ua haujlwm

// MUSIC ~~~~~~~~~~~~~~~~~~~~~~~~

const int buzzer = 10; // Txhais tus pin 10, tuaj yeem siv lwm PWM pins (5, 6 lossis 9) // Nco tseg pins 3 thiab 11 siv tsis tau thaum siv lub suab nrov hauv Arduino Uno const int songspeed = 1.5; // Hloov mus rau 2 rau qhov ua kom qeeb ntawm zaj nkauj, qhov loj dua tus lej ua rau qeeb zaj nkauj // *************************** ************** #define NOTE_C4 262 // Txhais qhov cim tseg zaus #define NOTE_D4 294 #define NOTE_E4 330 #define NOTE_F4 349 #define NOTE_G4 392 #define NOTE_A4 440 #define NOTE_B4 494 #define NOTE_C5 523 #define NOTE_D5 587 #define NOTE_E5 659 #define NOTE_F5 698 #define NOTE_G5 784 #define NOTE_A5 880 #define NOTE_B5 988 // ************************ ****************** int notes = {// Nco ntsoov ntawm zaj nkauj, 0 yog so/mem tes NOTE_E4, NOTE_G4, NOTE_A4, NOTE_A4, 0, NOTE_A4, NOTE_B4, NOTE_C5, NOTE_C5, 0, NOTE_C5, NOTE_D5, NOTE_B4, NOTE_B4, 0, NOTE_A4, NOTE_G4, NOTE_A4, 0} // ***************************************** int ntev = { / /sijhawm ntawm txhua qhov ntawv (hauv ms) Quarter Note tau teeb tsa rau 250 ms 125, 125, 250, 125, 125, 125, 125, 125, 250, 125, 125, 125, 125, 125, 250, 125, 125, 125, 125, 375, 125;

// KUV ~~~~~~~~~~~~~~~~~~~~~~~~

#include #include #include

// Pib dua Pin yog siv rau I2C lossis SPI

#define CAP1188_RESET 9

// CS pin tau siv rau software lossis kho vajtse SPI

#define CAP1188_CS 10

// Cov no tau hais tseg rau software SPI, rau kho vajtse SPI, txheeb xyuas koj

// board's SPI pins hauv Arduino cov ntaub ntawv #define CAP1188_MOSI 11 #define CAP1188_MISO 12 #define CAP1188_CLK 13

// Siv I2C, tsis muaj tus pin rov pib dua!

Adafruit_CAP1188 cap = Adafruit_CAP1188 ();

void teeb tsa () {

// MUSIC ~~~~~~~~~~~~~~~~~~~~~~ rau (int i = 0; i <203; i ++) {// 203 yog tag nrho cov suab paj nruag sau hauv nkauj int tos = ntev * nkauj; suab nrov (buzzer, sau ntawv , tos); // tone (tus pin, zaus, sijhawm);} // ncua sijhawm siv yog li nws tsis mus rau lub voj tom ntej ua ntej lub suab tiav ua si // Koj tuaj yeem nyem rov pib dua ntawm Arduino kom rov ua nkauj dua // NEOPIXEL ~~~ ~~~~~~~~~~~~~~~ currentPixel = 0; pixels.begin (); // Qhov no pib ua lub tsev qiv ntawv NeoPixel. pixels.show (); // Qhov no xa qhov hloov tshiab pixel xim rau kho vajtse.

// KUV ~~~~~~~~~~~~~~~~~~~~~~~~

Serial.begin (300); Serial.println ("CAP1188 xeem!"); yog (! cap.begin ()) {Serial.println ("CAP1188 tsis pom"); thaum (1); } Serial.println ("CAP1188 pom!");

}

void voj () {

// KOV + NEOPIXEL ~~~~~~~~~~~~~~~~~~~~~ uint8_t kov = cap.touched (); yog (kov == 0) {yog ((tsis tau kos npe ntev) (millis () - colorWipePreviousMillis)> = pixelsInterval) {colorWipePreviousMillis = millis (); colorWipe (pixels. Color (0, 255, 125)); }} lwm {yog ((tsis tau kos npe ntev) (millis () - colorWipePreviousMillis)> = pixelsInterval) {colorWipePreviousMillis = millis (); colorWipe (pixels. Color (100, 0, 150)); }}

rau (int kuv = 0; kuv = pixelsInterval) {

colorWipePreviousMillis = millis (); colorWipe (pixels. Color (0, 255, 125)); }} lwm {yog ((tsis tau kos npe ntev) (millis () - colorWipePreviousMillis)> = pixelsInterval) {colorWipePreviousMillis = millis (); colorWipe (pixels. Color (100, 0, 150)); }}

ncua (tos);

}

}

void colorWipe (uint32_t c) {

// NEOPIXEL ~~~~~~~~~~~~~~~~~~ // Tshem tawm cov xim pixels.setPixelColor (currentPixel, c); pixels.setPixelColor (currentPixel-1, pixels. Color (0, 0, 0)); pixels.show (); currentPixel ++; yog (currentPixel == NUMPIXELS) {currentPixel = 0; pixels.setPixelColor (7, pixels. Color (0, 0, 0));

}

}

Kauj Ruam 3: Kauj Ruam Ntxiv: Ua Stump 'Arduino Ready'

Kauj Ruam Ntxiv: Ua Stump 'Arduino Ready'
Kauj Ruam Ntxiv: Ua Stump 'Arduino Ready'
Kauj Ruam Ntxiv: Ua Stump 'Arduino Ready'
Kauj Ruam Ntxiv: Ua Stump 'Arduino Ready'
Kauj Ruam Ntxiv: Ua Stump 'Arduino Ready'
Kauj Ruam Ntxiv: Ua Stump 'Arduino Ready'

Yog tias koj txiav txim siab siv tsob ntoo ntoo koj yuav tsum ua cov hauv qab no.

  • Tau txais tsob ntoo ntoo (Kuv tau txais ib qho los ntawm tsob ntoo Christmas qub dawb)
  • Ntsuas koj Arduino thiab saib yuav ua li cas koj xav kom muaj cov hlua nyob hauv cov ntoo ntoo
  • Hollow tawm lub stump (Kuv siv lub tshuab laum los ntawm tsev kawm ntawv)
  • Xuab zeb qhov ntxhib tawm
  • Ntxiv kev lom zem me me

Cov ntsiab lus kuv ntxiv yog lub logo me me uas kuv tau ua nrog lub tshuab txiav laser. Kuv kuj tau teeb tag nrho kuv cov khoom siv hluav taws xob sab hauv ntawm tus pas hauv kuv tsob ntoo thiab kuv ntxiv cov tsiaj txhu cov khoom ntim rau sab nraud kom pom lub teeb dhau los thiab muab qhov me me ntxiv rau qhov muag.

Pom zoo: