0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

NeoPixel 1515 LEDテープをarduinoで光らせる

Last updated at Posted at 2020-02-02

目的

NeoPixel 1515 LEDテープをarduinoで光らせた際の備忘録です

準備

Arduino Uno
NeoPixel 1515 LEDテープ

Adafruit_NeoPixelライブラリをArduinoIDEにインストールします

Adafruit_NeoPixel

回路図

Arduino - NeoPixel
5V - 5V
PIN6 - D0
GND - GND

sample.png

※ピンを半田付けする際に、向きがあるようです。
テープに印字されている矢印(→)の向きに従って半田付けするようにしましょう。

コード

サンプルコードを利用します。

simple
// NeoPixel Ring simple sketch (c) 2013 Shae Erisson
// released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library

# include <Adafruit_NeoPixel.h>
# ifdef __AVR__
  #include <avr/power.h>
# endif

// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1
# define PIN            6

// How many NeoPixels are attached to the Arduino?
# define NUMPIXELS      16

// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int delayval = 500; // delay for half a second

void setup() {
  // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
# if defined (__AVR_ATtiny85__)
  if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
# endif
  // End of trinket special code

  pixels.begin(); // This initializes the NeoPixel library.
}

void loop() {

  // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.

  for(int i=0;i<NUMPIXELS;i++){

    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor(i, pixels.Color(0,150,0)); // Moderately bright green color.

    pixels.show(); // This sends the updated pixel color to the hardware.

    delay(delayval); // Delay for a period of time (in milliseconds).

  }
}

テスト

光ればOKです。

追記

こちらを参考にさせて頂きランダムに光るプログラムを作成しました。
 

sample
# include <Adafruit_NeoPixel.h>
# define PIN 6
# define NUMPIN 75
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIN, PIN, NEO_GRB + NEO_KHZ800);


void setup() {
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
  Serial.begin(9600);
}

void loop() {
  int sensor0 = abs(analogRead(A0)-512);

  //回数
  for(int i=0; i<NUMPIN; i++){
      if(sensor0>100){
        int r = random(0,NUMPIN);
          int cR = random(0,256);
          int cG = random(0,256);
          int cB = random(0,256);
          strip.setPixelColor(r, strip.Color(cR,cG,cB));
      }
        strip.show();
  }
  
//  //All off
  for(int i=0; i<NUMPIN; i++){
    strip.setPixelColor(i, strip.Color(0,0,0));
    strip.show();
  }

  Serial.println(sensor0);

}

CodingError対策

線を繋いでいるが、NeoPixelが光らない

ピンを半田付けする際に、向きがあるようです。
テープに印字されている矢印(→)の向きに従って半田付けするようにしましょう。

参考

超薄型NeoPixel 1515 LEDテープ (幅4mm、長さ0.5m、75個LED)
NeoPixelをMaxで光らせるまで
Adafruit_NeoPixel
Arduinoに接続したNeoPixelの色と明るさをシリアル通信で制御する
ライブで大活躍!音に反応して光るサバゲーマスク!
春の電子回路WS
ArduinoでLEDテープライトを光らせる
ArduinoでLEDテープを光らせて遊ぶ
【Arduino】LEDシリアルテープを光らせる

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?