3D pen 으로 빛나는 Halloween 호박 가면 만들기 !!!!!
3dpen 으로 jack o’lantern 할로윈 호박이죠 ㅋㅋ 를 만들어 봤습니다. 자세한 내용은 아래 영상을 참조해 주세요 ㅎㅎ
준비물
찰흙 4개 – https://coupa.ng/bjm27N
찰흙칼 – https://coupa.ng/bjm27N
다크 오렌지 필라멘트 40M – https://coupa.ng/bjm27j
투명 필라멘트 – https://coupa.ng/bjm27j
초록 필라멘트 – https://coupa.ng/bjm27j
검정 필라멘트 – https://coupa.ng/bjm27j
ws2812b 11개 – https://coupa.ng/bjm24k
아두이노 나노 – https://coupa.ng/bjm24Q
9V 건전지 소켓 – https://coupa.ng/bjm24Q
스위치 – https://coupa.ng/bjm29q
(옵션)
100uf 커패시터
320옴 저항
* 회로의 안정성을 위해 100uF 케페시터를 5V 와 GND 에 달아줄 거고 320옴은 데이터 입력핀에 달아 줍니다.
WS2812b와 아두이노 나노
ws2812b는 5V를 전원으로 하는 LED Strip 입니다. LED 한개당 흐를 수 있는 최대 전류는 60ma 정도 입니다.
아두이노 나노에 9V 입력이 들어갔을 때 5V 핀에 흐를 수 있는 전류는 max 400ma 정도입니다.
즉 이론상으로는 아두이노 5V 핀으로는 LED 6개만 붙일 수 있지만 프로그램에서 LED 밝기를 제한 할 수 있고 모든 LED를 white로 틀일이 없어서 11개 까지 붙혔습니다.
아두이노 코드
코드를 작성하기 전에 FastLED 라이브러리를 설치해야 합니다.

위 그림처럼 라이브러리 관리… 를 클릭하면 라이브러리 메니저가 나오는데 여기서 FastLED를 검샛하셔서 설치하면 됩니다.
설치 후 아래 코드를 입력해주세요 !
저는 나노를 사논지가 좀 되서 그런지 프로세서를 아래처럼 해야 업로드가 정상적으로 동작 하더라고요 .. 최근에 사신 분은 그냥 ATmega328P 로 하셔도 될 것 같습니다.

자 이제 아래 코드를 복붙해서 아두이노에 넣어 주세요
참고로 아래 코드는 FastLED 에 DemoReel100 코드를 수정한 내용 입니다.
#include <FastLED.h> FASTLED_USING_NAMESPACE // FastLED "100-lines-of-code" demo reel, showing just a few // of the kinds of animation patterns you can quickly and easily // compose using FastLED. // // This example also shows one easy way to define multiple // animations patterns and have them automatically rotate. // // -Mark Kriegsman, December 2014 #if defined(FASTLED_VERSION) && (FASTLED_VERSION < 3001000) #warning "Requires FastLED 3.1 or later; check github for latest code." #endif #define DATA_PIN 6 //#define CLK_PIN 4 #define LED_TYPE WS2812 #define COLOR_ORDER GRB #define NUM_LEDS 11 CRGB leds[NUM_LEDS]; #define BRIGHTNESS 128 #define FRAMES_PER_SECOND 120 void setup() { delay(3000); // 3 second delay for recovery // tell FastLED about the LED strip configuration FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip); //FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip); // set master brightness control FastLED.setBrightness(BRIGHTNESS); } // List of patterns to cycle through. Each is defined as a separate function below. typedef void (*SimplePatternList[])(); SimplePatternList gPatterns = { Normal, NormalBlink, NormalFadding, rainbow, rainbowWithGlitter, confetti, sinelon, juggle, bpm }; uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current uint8_t gHue = 0; // rotating "base color" used by many of the patterns void loop() { // Call the current pattern function once, updating the 'leds' array gPatterns[gCurrentPatternNumber](); // send the 'leds' array out to the actual LED strip FastLED.show(); // insert a delay to keep the framerate modest FastLED.delay(1000/FRAMES_PER_SECOND); // do some periodic updates EVERY_N_MILLISECONDS( 20 ) { gHue++; } // slowly cycle the "base color" through the rainbow EVERY_N_SECONDS( 5 ) { nextPattern(); } // change patterns periodically } #define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0])) void nextPattern() { // add one to the current pattern number, and wrap around at the end gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE( gPatterns); } void Normal(){ for (int i = 0; i< NUM_LEDS; i++) { if (i == 3){leds[i] = CRGB::DarkGreen; } else{leds[i] = CRGB::DarkOrange; } } } void NormalBlink(){ for (int i = 0; i< NUM_LEDS; i++) { if (i == 3){leds[i] = CRGB::DarkGreen; } else{leds[i] = CRGB::DarkOrange; } } FastLED.show(); delay(500); for (int i = 0; i< NUM_LEDS; i++) { leds[i] = CRGB::Black; } FastLED.show(); delay(500); } void NormalFadding(){ for(int j = 250; j > 0; j--){ for(int i = 0; i < NUM_LEDS; i++) { if (i == 3){leds[i] = CRGB::DarkGreen; } else{leds[i] = CRGB::DarkOrange; } leds[i].nscale8(j); } delay(10); FastLED.show(); } for(int j = 0; j < 250; j++){ for(int i = 0; i < NUM_LEDS; i++) { if (i == 3){leds[i] = CRGB::DarkGreen; } else{leds[i] = CRGB::DarkOrange; } leds[i].nscale8(j); } delay(10); FastLED.show(); } } void rainbow() { // FastLED's built-in rainbow generator fill_rainbow( leds, NUM_LEDS, gHue, 7); } void rainbowWithGlitter() { // built-in FastLED rainbow, plus some random sparkly glitter rainbow(); addGlitter(80); } void addGlitter( fract8 chanceOfGlitter) { if( random8() < chanceOfGlitter) { leds[ random16(NUM_LEDS) ] += CRGB::White; } } void confetti() { // random colored speckles that blink in and fade smoothly fadeToBlackBy( leds, NUM_LEDS, 10); int pos = random16(NUM_LEDS); leds[pos] += CHSV( gHue + random8(64), 200, 255); } void sinelon() { // a colored dot sweeping back and forth, with fading trails fadeToBlackBy( leds, NUM_LEDS, 20); int pos = beatsin16( 13, 0, NUM_LEDS-1 ); leds[pos] += CHSV( gHue, 255, 192); } void bpm() { // colored stripes pulsing at a defined Beats-Per-Minute (BPM) uint8_t BeatsPerMinute = 62; CRGBPalette16 palette = PartyColors_p; uint8_t beat = beatsin8( BeatsPerMinute, 64, 255); for( int i = 0; i < NUM_LEDS; i++) { //9948 leds[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10)); } } void juggle() { // eight colored dots, weaving in and out of sync with each other fadeToBlackBy( leds, NUM_LEDS, 20); byte dothue = 0; for( int i = 0; i < 8; i++) { leds[beatsin16( i+7, 0, NUM_LEDS-1 )] |= CHSV(dothue, 200, 255); dothue += 32; } }
블로그 구독하기 !!