편집 기록

편집 기록
  • 프로필 ᅟᅟᅟᅟ님의 편집
    날짜2022.10.04

    아두이노 네오픽셀 질문


    안녕하세요 아두이노로 네오픽셀을 코딩하는데 colorwipe색이 전체가 반복이 되는데 각각의 핀의 색을 다르게 만들고 싶어요 도움이 필요합니다.

    #include <Adafruit_NeoPixel.h>
    #ifdef __AVR__
      #include <avr/power.h>
    #endif
    
    #define PIN 2
    Adafruit_NeoPixel strip1 = Adafruit_NeoPixel(8, PIN, NEO_GRB + NEO_KHZ800);
    
    #define PIN 3
    Adafruit_NeoPixel strip2 = Adafruit_NeoPixel(8, PIN, NEO_GRB + NEO_KHZ800);
    
    #define PIN 4
    Adafruit_NeoPixel strip3 = Adafruit_NeoPixel(9, PIN, NEO_GRB + NEO_KHZ800);
    
    #define PIN 5
    Adafruit_NeoPixel strip4 = Adafruit_NeoPixel(12, PIN, NEO_GRB + NEO_KHZ800);
    
    #define PIN 6
    Adafruit_NeoPixel strip5 = Adafruit_NeoPixel(8, PIN, NEO_GRB + NEO_KHZ800);
    
    #define PIN 7
    Adafruit_NeoPixel strip6 = Adafruit_NeoPixel(8, PIN, NEO_GRB + NEO_KHZ800);
    
    
    void setup(){
    
      {
    #if defined (__AVR_ATtiny85__)
       if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
      #endif
      strip1.begin();
      strip1.show(); // Initialize all pixels to 'off'
         strip1.setBrightness(50); // 네오픽셀의 밝기 설정(최대 255까지 가능)
      strip2.begin();
      strip2.show(); // Initialize all pixels to 'off'
         strip2.setBrightness(50); // 네오픽셀의 밝기 설정(최대 255까지 가능)
      strip3.begin();
      strip3.show(); // Initialize all pixels to 'off'
         strip3.setBrightness(50); // 네오픽셀의 밝기 설정(최대 255까지 가능)
      strip4.begin();
      strip4.show(); // Initialize all pixels to 'off'
         strip4.setBrightness(50); // 네오픽셀의 밝기 설정(최대 255까지 가능)
      strip5.begin();
      strip5.show(); // Initialize all pixels to 'off'
         strip5.setBrightness(50); // 네오픽셀의 밝기 설정(최대 255까지 가능)
      strip6.begin();
      strip6.show(); // Initialize all pixels to 'off'
         strip6.setBrightness(50); // 네오픽셀의 밝기 설정(최대 255까지 가능)
    
      }
    }
    void loop(){
    
      {
    
      colorWipe(strip1.Color(0,255,0,0),1000); // 켜짐
      delay(10);
      colorWipe(strip1.Color(255,255,255,0),0); // 꺼짐
      delay(10);
          colorWipe(strip2.Color(0,0,255,0),1000); // 켜짐
      delay(10);
      colorWipe(strip2.Color(255,255,255,0),0); // 꺼짐
      delay(10);
          colorWipe(strip3.Color(255,255,0,0),1000); // 켜짐
      delay(10);
      colorWipe(strip3.Color(255,255,255,0),0); // 꺼짐
      delay(10);
          colorWipe(strip4.Color(0,255,255,0),1000); // 켜짐
      delay(10);
      colorWipe(strip4.Color(255,255,255,0),0); // 꺼짐
      delay(10);
          colorWipe(strip5.Color(255,0,255,0),1000); // 켜짐
      delay(10);
      colorWipe(strip5.Color(255,255,255,0),0); // 꺼짐
      delay(10);
          colorWipe(strip6.Color(255,0,0,0),1000); // 켜짐
      delay(10);
      colorWipe(strip6.Color(255,255,255,0),0); // 꺼짐
      delay(10);
      }
    }
    
    void colorWipe(uint32_t color, int wait) 
    {
      for(int a=0; a<strip1.numPixels(); a++) 
      {                                       // For each pixel in strip...
        strip1.setPixelColor(a, color);         //  Set pixel's color (in RAM)
        strip1.show();                          //  Update strip to match
        delay(wait);                           //  Pause for a moment
      }
       for(int a=0; a<strip2.numPixels(); a++) 
      {                                                      // For each pixel in strip...
        strip2.setPixelColor(a, color);                 //  Set pixel's color (in RAM)
        strip2.show();                                   //  Update strip to match
        delay(wait);                                     //  Pause for a moment
      }  
    for(int a=0; a<strip3.numPixels(); a++) 
      {                                                      // For each pixel in strip...
        strip3.setPixelColor(a, color);                 //  Set pixel's color (in RAM)
        strip3.show();                                   //  Update strip to match
        delay(wait);                                     //  Pause for a moment
      } 
     for(int a=0; a<strip4.numPixels(); a++) 
      {                                                      // For each pixel in strip...
        strip4.setPixelColor(a, color);                 //  Set pixel's color (in RAM)
        strip4.show();                                   //  Update strip to match
        delay(wait);                                     //  Pause for a moment
      }  
      for(int a=0; a<strip5.numPixels(); a++) 
      {                                                      // For each pixel in strip...
        strip5.setPixelColor(a, color);                 //  Set pixel's color (in RAM)
        strip5.show();                                   //  Update strip to match
        delay(wait);                                     //  Pause for a moment
      }  
      for(int a=0; a<strip6.numPixels(); a++) 
      {                                                      // For each pixel in strip...
        strip6.setPixelColor(a, color);                 //  Set pixel's color (in RAM)
        strip6.show();                                   //  Update strip to match
        delay(wait);                                     //  Pause for a moment
      }  
    
    }
    
  • 프로필 lemontoce11@gmail.com님의 편집
    날짜2022.10.04

    아두이노 네오픽셀 질문


    안녕하세요 아두이노로 네오픽셀을 코딩하는데 colorwipe색이 전체가 반복이 되는데 각각의 핀의 색을 다르게 만들고 싶어요 도움이 필요합니다.

    include

    ifdef AVR

    #include

    endif

    define PIN 2

    Adafruit_NeoPixel strip1 = Adafruit_NeoPixel(8, PIN, NEO_GRB + NEO_KHZ800);

    define PIN 3

    Adafruit_NeoPixel strip2 = Adafruit_NeoPixel(8, PIN, NEO_GRB + NEO_KHZ800);

    define PIN 4

    Adafruit_NeoPixel strip3 = Adafruit_NeoPixel(9, PIN, NEO_GRB + NEO_KHZ800);

    define PIN 5

    Adafruit_NeoPixel strip4 = Adafruit_NeoPixel(12, PIN, NEO_GRB + NEO_KHZ800);

    define PIN 6

    Adafruit_NeoPixel strip5 = Adafruit_NeoPixel(8, PIN, NEO_GRB + NEO_KHZ800);

    define PIN 7

    Adafruit_NeoPixel strip6 = Adafruit_NeoPixel(8, PIN, NEO_GRB + NEO_KHZ800);

    void setup(){

    {

    if defined (AVR_ATtiny85)

    if (F_CPU == 16000000) clock_prescale_set(clock_div_1); #endif strip1.begin(); strip1.show(); // Initialize all pixels to 'off' strip1.setBrightness(50); // 네오픽셀의 밝기 설정(최대 255까지 가능) strip2.begin(); strip2.show(); // Initialize all pixels to 'off' strip2.setBrightness(50); // 네오픽셀의 밝기 설정(최대 255까지 가능) strip3.begin(); strip3.show(); // Initialize all pixels to 'off' strip3.setBrightness(50); // 네오픽셀의 밝기 설정(최대 255까지 가능) strip4.begin(); strip4.show(); // Initialize all pixels to 'off' strip4.setBrightness(50); // 네오픽셀의 밝기 설정(최대 255까지 가능) strip5.begin(); strip5.show(); // Initialize all pixels to 'off' strip5.setBrightness(50); // 네오픽셀의 밝기 설정(최대 255까지 가능) strip6.begin(); strip6.show(); // Initialize all pixels to 'off' strip6.setBrightness(50); // 네오픽셀의 밝기 설정(최대 255까지 가능)

    } } void loop(){

    {

    colorWipe(strip1.Color(0,255,0,0),1000); // 켜짐 delay(10); colorWipe(strip1.Color(255,255,255,0),0); // 꺼짐 delay(10); colorWipe(strip2.Color(0,0,255,0),1000); // 켜짐 delay(10); colorWipe(strip2.Color(255,255,255,0),0); // 꺼짐 delay(10); colorWipe(strip3.Color(255,255,0,0),1000); // 켜짐 delay(10); colorWipe(strip3.Color(255,255,255,0),0); // 꺼짐 delay(10); colorWipe(strip4.Color(0,255,255,0),1000); // 켜짐 delay(10); colorWipe(strip4.Color(255,255,255,0),0); // 꺼짐 delay(10); colorWipe(strip5.Color(255,0,255,0),1000); // 켜짐 delay(10); colorWipe(strip5.Color(255,255,255,0),0); // 꺼짐 delay(10); colorWipe(strip6.Color(255,0,0,0),1000); // 켜짐 delay(10); colorWipe(strip6.Color(255,255,255,0),0); // 꺼짐 delay(10); } }

    void colorWipe(uint32_t color, int wait) { for(int a=0; a<strip1.numPixels(); a++) { // For each pixel in strip... strip1.setPixelColor(a, color); // Set pixel's color (in RAM) strip1.show(); // Update strip to match delay(wait); // Pause for a moment } for(int a=0; a<strip2.numPixels(); a++) { // For each pixel in strip... strip2.setPixelColor(a, color); // Set pixel's color (in RAM) strip2.show(); // Update strip to match delay(wait); // Pause for a moment }
    for(int a=0; a<strip3.numPixels(); a++) { // For each pixel in strip... strip3.setPixelColor(a, color); // Set pixel's color (in RAM) strip3.show(); // Update strip to match delay(wait); // Pause for a moment } for(int a=0; a<strip4.numPixels(); a++) { // For each pixel in strip... strip4.setPixelColor(a, color); // Set pixel's color (in RAM) strip4.show(); // Update strip to match delay(wait); // Pause for a moment }
    for(int a=0; a<strip5.numPixels(); a++) { // For each pixel in strip... strip5.setPixelColor(a, color); // Set pixel's color (in RAM) strip5.show(); // Update strip to match delay(wait); // Pause for a moment }
    for(int a=0; a<strip6.numPixels(); a++) { // For each pixel in strip... strip6.setPixelColor(a, color); // Set pixel's color (in RAM) strip6.show(); // Update strip to match delay(wait); // Pause for a moment }

    }