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 3 years have passed since last update.

シリアルLEDでPCをゲーミング使用に光らせるプログラム

Posted at

初めに

先日ゲーミングPCを入手しました。
ゲーミングPCといえば、、、

光っててカッコいい!!!

けどなんか物足りないなあ、もっと光らせたいなあ
と思ったので、今回はシリアルLEDを使ってゲーミングPCをさらに光らせます。

ゲーミング使用でない(光らない)デスクトップPCをお持ちの方必見です。

今回使用したもの

  • Arduino  (偽物がamazonで¥1,300くらい)
  • シリアルLED  (¥1,000以内で手に入ります)
  • 配線材  (はんだ付けが面倒なのでジャンパーワイヤーがオススメ)

シリアルLEDは8×8のパネル状のものを使用しましたが、テープ状の方が省スペースで隠しやすくオススメです。

プログラム

//シリアルLEDをゲーミングPCみたいに発光させるプログラム

//設定パラメータ====================================
int Speed = 150; //色が変わる早さ [ms]
int Power = 100; //LEDの明るさ [1~255]
//================================================

//ライブラリimport・LED数・出力ピン定義
# include <FastLED.h> // https://github.com/FastLED/FastLED からインクルード
# define NUM_LEDS 64  // シリアルLEDに搭載されている合計LED数
# define DATA_PIN 3   // 出力ピン番号

CRGB leds[NUM_LEDS];  //配列はシリアルLED上の各LEDに対応
int R = Power;
int G = 0;
int B = 0;

void setup() {
  Serial.begin(9600);
  FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
}

void loop() {
  //FHASE 1
  while(G < Power){
    for(int k = 0; k < NUM_LEDS; k++){
      leds[k] = CRGB(R,G,B);
    }
    FastLED.show(); //点灯
    delay(Speed); //点灯持続時間
    R -= 1;
    G += 1;
  }

  //FHASE 2
  while(B < Power){
    for(int k = 0; k < NUM_LEDS; k++){
      leds[k] = CRGB(R,G,B);
    }
    FastLED.show(); //点灯
    delay(Speed); //点灯持続時間
    G -= 1;
    B += 1;
  }
  
  //FHASE 3
  while(R < Power){
    for(int k = 0; k < NUM_LEDS; k++){
      leds[k] = CRGB(R,G,B);
    }
    FastLED.show(); //点灯
    delay(Speed); //点灯持続時間
    B -= 1;
    R += 1;
  }
}

終わりに

こういうプログラムをサクッと作れるようになってきて嬉しいです。
高校生くらいの夏のプログラミング教室とかで使えそうなネタだなあと思いました。
しょうもない記事でもいいのでもっとアップしていきたいですね^^;

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?