2025 Avtor: John Day | [email protected]. Nazadnje spremenjeno: 2025-01-13 06:58
V tem videu vam bom pokazal, kako narediti edinstven umetniški projekt doma z LED trakom in zvokom.
Korak: Video o projektu
LED trak -
MP3 predvajalnik -
Infrardeči senzor -
Mikrokrmilnik -
Priključek -
Adapter -
Regulator napetosti -
Zvočnik -
Micro SD -
Kondenzator -
Upor -
Preklopno stikalo -
Spajkalna orodja -
2. korak: Shema in Gerber
Pridobite tablo -
3. korak: izvorna koda
Izvorna koda:
#vključi
#include "SoftwareSerial.h" #include "DFRobotDFPlayerMini.h" #define NUM_LEDS_PER_STRIP 70 #define BRIGHTNESS 200 #define LED1pin 5 #define LED2pin 6 #define LED3pin 7 const int IR1pin = A0; const int IR2pin = A1; const int IR3pin = A2; Barva LED LED CRGB [NUM_LEDS_PER_STRIP]; CRGB LED2 barva [NUM_LEDS_PER_STRIP]; CRGB LED3 barva [NUM_LEDS_PER_STRIP]; SoftwareSerial mySoftwareSerial (10, 11); // RX, TX DFRobotDFPlayerMini mojDFPlayer; void printDetail (vrsta uint8_t, vrednost int); void setup () {mySoftwareSerial.begin (9600); Serial.begin (115200); if (! myDFPlayer.begin (mySoftwareSerial)) {Serial.println (F ("Ne morem začeti:")); Serial.println (F ("1. Prosimo, ponovno preverite povezavo!")); Serial.println (F ("2. Prosimo, vstavite kartico SD!")); medtem ko (res); } pinMode (IR1pin, INPUT); pinMode (IR2pin, INPUT); pinMode (IR3pin, INPUT); myDFPlayer.volume (20); myDFPlayer. EQ (DFPLAYER_EQ_CLASSIC); myDFPlayer.outputDevice (DFPLAYER_DEVICE_SD); FastLED.addLeds (LED1 barva, NUM_LEDS_PER_STRIP); FastLED.addLeds (LED2 barva, NUM_LEDS_PER_STRIP); FastLED.addLeds (LED3 barva, NUM_LEDS_PER_STRIP); FastLED.setBrightness (SVETLOST); } void loop () {if (digitalRead (IR1pin) == LOW) {LED1show (); } if (digitalRead (IR2pin) == LOW) {LED2show (); } if (digitalRead (IR3pin) == LOW) {LED3show (); }} void LED1show () {myDFPlayer.play (1); za (int i = 0; i