Blazing WS2812 LED strip | Pegboard |
DFP layer Mini player module | Hot glue gun & glue stick |
Trumpet | Cotton |
High frequency relay | Leads |
Pyroelectric infrared sensor for human body | Masking tape |
5V Voltage Step Up Boost Module | Light Emitting Diodes |
Arduino Pro mini | A plastic bottle |
Self-locking switch | Steering arm |
220 Ohm Resistor | |
Power supply connector | |
Color pin header | |
1000mA lithium battery | |
16v330uF capacitor | |
16G memory disk |
Circuit Diagram
Making procedure
Step One: Hardware Making Procedure?Connect each hardware with reference to my circuit diagram?
1. Weld the power supply connector, self-locking switch, battery interface, light emitting diodes and resistor with batteries and switch boards according to the circuit diagram.
2. Weld the 3.7V and 5V voltage step up boost module in parallel connection on the switch board.
3. Use pegboard, color pin header and capacitor to weld a sensor shield; weld the digital pins of D6, D9 and D13 in yellow line on the Arduino mini board separately with the yellow pin headers on the sensor shield.
4. Weld output terminal of the voltage step up boost module with the sensor shield terminal as completion for the whole welding part. Up next is mainly to connect the sensor and deal with the performance of it.
5. Use eight WS2812 LED strips as a whole bunch, cut it with scissors into four sections, before welding them together with leads.
6. The main purpose of using relay is to detect if there is human body coming close with pyroelectric infrared sensor. When the contact of the relay is closing up, the DFPlayer Mini is powered on. Meanwhile, long press the switch to connect ADKEY 1 with negative pole in short circuit, so that the DFPlayer Mini can repeat the first song. The actual test performs better than using serial port control. Connect the relay and DFPlayer Mini module with dupont line. The rest of the two dupont lines are plugged into the positive and negative pin headers separately on the sensor shield. Insert the memory disk in which the already downloaded lightning sound was stored.
7. Plug the human pyroelectric infrared sensor into D9 pin on the sensor shield; insert the WS2812 LED strip into D6 pin on the shield board.
8. Plug the relay into the D13 pin on the sensor shield, connect the DFPlayer Mini module, link the circuit and check the performance of each hardware.
Step Two Upload codes onto Arduino board#include <Adafruit_NeoPixel.h>
#define PIXEL_PIN 6 //??????
#define SENSOR_PIN 9 //???????
#define SPEAKER_PIN 13 //????????
#define PIXEL_COUNT 32 //?????
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800);
int randomNumber;
void setup() {
pinMode(SPEAKER_PIN, OUTPUT);
digitalWrite(SPEAKER_PIN, LOW);
strip.begin();
strip.show();
pinMode(SENSOR_PIN, INPUT);
randomSeed(analogRead(0));
Serial.begin(9600);
}
void loop() {
if( digitalRead(SENSOR_PIN) == HIGH){
digitalWrite(SPEAKER_PIN, HIGH);
randomNumber = random(300);
Serial.println(randomNumber % 67);
thunder_strike(randomNumber % 67);
delay(3000);
digitalWrite(SPEAKER_PIN, LOW);
}else{
if(millis() % 100000 == 0){
for(int i=20; i<100; i++){
colorWipe(strip.Color(i,i-20,0),0);
}
for(int i=100; i>20; i--){
colorWipe(strip.Color(i,i-20,0),0);
}
colorWipe(strip.Color(0,0,0),0);
delay(3000);
}
}
}
void thunder_strike( int type) {
if(type < 20){
colorWipe_short(0, PIXEL_COUNT, strip.Color(73, 147, 255), 3);
colorWipe(strip.Color(0, 0, 0), 0);
delay(500);
colorWipe_short(0, PIXEL_COUNT, strip.Color(73, 147, 255), 3);
delay(20);
colorWipe(strip.Color(0, 0, 0), 0);
delay(500);
}else if(type < 40){
colorWipe(strip.Color(104, 94, 94), 3);
colorWipe(strip.Color(0,0,0), 0);
delay(500);
colorWipe(strip.Color(104, 94, 94), 3);
delay(20);
colorWipe(strip.Color(0,0,0), 0);
delay(500);
}else if(type < 60){
colorWipe(strip.Color(181, 165, 95), 3);
delay(1000);
colorWipe(strip.Color(0,0,0), 0);
delay(100);
colorWipe(strip.Color(181, 165, 95), 3);
delay(500);
colorWipe(strip.Color(0,0,0), 0);
delay(500);
}else{
rainbowCycle(5);
colorWipe(strip.Color(0,0,0), 0);
}
}
void colorWipe_short(uint16_t be, uint16_t en, uint32_t c, uint8_t wait){
for (uint16_t i = be; i < en; i++) {
strip.setPixelColor(i, c);
strip.show();
delay(wait);
}
}
// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
for (uint16_t i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, c);
strip.show();
delay(wait);
}
}
void rainbow(uint8_t wait) {
uint16_t i, j;
for (j = 0; j < 256; j++) {
for (i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel((i + j) & 255));
}
strip.show();
delay(wait);
}
}
// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
for (j = 0; j < 256 * 5; j++) { // 5 cycles of all colors on wheel
for (i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
}
strip.show();
delay(wait);
}
}
void theaterChase(uint32_t c, uint8_t wait) {
for (int j = 0; j < 10; j++) { //do 10 cycles of chasing
for (int q = 0; q < 3; q++) {
for (int i = 0; i < strip.numPixels(); i = i + 3) {
strip.setPixelColor(i + q, c); //turn every third pixel on
}
strip.show();
delay(wait);
for (int i = 0; i < strip.numPixels(); i = i + 3) {
strip.setPixelColor(i + q, 0); //turn every third pixel off
}
}
}
}
//Theatre-style crawling lights with rainbow effect
void theaterChaseRainbow(uint8_t wait) {
for (int j = 0; j < 256; j++) { // cycle all 256 colors in the wheel
for (int q = 0; q < 3; q++) {
for (int i = 0; i < strip.numPixels(); i = i + 3) {
strip.setPixelColor(i + q, Wheel( (i + j) % 255)); //turn every third pixel on
}
strip.show();
delay(wait);
for (int i = 0; i < strip.numPixels(); i = i + 3) {
strip.setPixelColor(i + q, 0); //turn every third pixel off
}
}
}
}
// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if (WheelPos < 85) {
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
}
if (WheelPos < 170) {
WheelPos -= 85;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
WheelPos -= 170;
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}