# 光る箱

**URL:** <https://forum.digikey.com/t/topic/16327>\
**Category:** 日本語フォーラム\
**Created:** [August 30, 2021, 1:50pm UTC](https://forum.digikey.com/t/topic/16327 "2021-08-30T13:50:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tsuneharu\_Fuji](https://avatars.discourse-cdn.com/v4/letter/t/54ee81/32.png) [@Tsuneharu\_Fuji](https://forum.digikey.com/u/Tsuneharu_Fuji)\
**Post date:** [August 30, 2021, 1:50pm UTC](https://forum.digikey.com/t/topic/16327/1 "2021-08-30T13:50:07Z")

</div>

以下は、私が3Dプリンティングのトータルプロセスを学び、Arduinoのプログラミングを学ぶためのプロジェクトでした。

[![Fully%20assembled%20box](https://global.discourse-cdn.com/digikey/optimized/2X/0/06ec2aa35042122732b804e60c08af9cbbcdeebe_2_333x250.jpeg)

](https://global.discourse-cdn.com/digikey/original/2X/0/06ec2aa35042122732b804e60c08af9cbbcdeebe.jpeg "Fully%20assembled%20box")

プログラミングから始めましょう。  
このプログラムは、Arduinoが例として挙げている「Fade」と「BlinkWithoutDelay」に示されているコンセプトに基づいています。  
この2つのコンセプトを組み合わせることで、LEDの明るさをフェードアップ/ダウンさせるだけでなく、使用しているLEDを循環させ、同時にその色も循環させることができるようになりました。  
「delay()」関数は、遅延時間が実行されている間は、コード内の他の処理を行うことができませんので、ご注意ください。

使用しているコードは、全体的なタスクを遂行するための最良の方法ではないかもしれませんが、私の言語知識の範囲内で、やりたかったことは実現しています。  
以下のコードには、各部分が何をするのかを説明するためのコメントがあります。

```auto
// The below names the pins that will be controlling which LED will be on.:
int Green1 = 22;
int Red1 = 23;
int Green2 = 24;
int Red2 = 25;
int Green3 = 26;
int Red3 = 27;
int Green4 = 28;
int Red4 = 29;
int Green5 = 30;
int Red5 = 31;
int Green6 = 32;
int Red6 = 33;
int Blue1 = 34;
int Blue2 = 35;
int Blue3 = 36;
int Blue4 = 37;
int Blue5 = 38;
int Blue6 = 39;
// This is a part of the set up for the timing of the LED control.:
unsigned long previousMillis1 = 0;
unsigned long previousMillis2 = 0;
// Another part of the timing.:
int interval1 = 20; //For controlling the overall speed of the fading affect.:
int interval2 = 1000; //This value will change as the code it running. It is for indicating when the LEDs should change states.:
// The below provides a known stating point for the code and the LEDs.:
int Redstate1 = LOW;
int Redstate2 = LOW;
int Redstate3 = LOW;
int Redstate4 = LOW;
int Redstate5 = LOW;
int Redstate6 = LOW;
int Bluestate1 = LOW;
int Bluestate2 = LOW;
int Bluestate3 = LOW;
int Bluestate4 = LOW;
int Bluestate5 = LOW;
int Bluestate6 = LOW;
int Greenstate1 = LOW;
int Greenstate2 = LOW;
int Greenstate3 = LOW;
int Greenstate4 = LOW;
int Greenstate5 = LOW;
int Greenstate6 = LOW;
// Apart of the fading affect.:
int brightness = 0; //starting point for the brightness of the fade.:
int fadeAmount = 5; //For controlling how much the brightness will change when it does change.:
// These names the pins that will be controlling the LED’s fading.:
int Led1 = 7;
int Led2 = 6;
int Led3 = 5;
int Led4 = 4;
int Led5 = 3;
int Led6 = 2;
void setup() {
// The below is the setup code, to run once just before the looping.:
pinMode (Green1, OUTPUT);
pinMode (Red1, OUTPUT);
pinMode (Blue1, OUTPUT);
pinMode (Green2, OUTPUT);
pinMode (Red2, OUTPUT);
pinMode (Blue2, OUTPUT);
pinMode (Green3, OUTPUT);
pinMode (Red3, OUTPUT);
pinMode (Blue3, OUTPUT);
pinMode (Green4, OUTPUT);
pinMode (Red4, OUTPUT);
pinMode (Blue4, OUTPUT);
pinMode (Green5, OUTPUT);
pinMode (Red5, OUTPUT);
pinMode (Blue5, OUTPUT);
pinMode (Green6, OUTPUT);
pinMode (Red6, OUTPUT);
pinMode (Blue6, OUTPUT);
pinMode (Led1, OUTPUT);
pinMode (Led2, OUTPUT);
pinMode (Led3, OUTPUT);
pinMode (Led4, OUTPUT);
pinMode (Led5, OUTPUT);
pinMode (Led6, OUTPUT);
digitalWrite (Red1, Redstate1);
digitalWrite (Red2, Redstate2);
digitalWrite (Red3, Redstate3);
digitalWrite (Red4, Redstate4);
digitalWrite (Red5, Redstate5);
digitalWrite (Red6, Redstate6);
digitalWrite (Green1, Greenstate1);
digitalWrite (Green2, Greenstate2);
digitalWrite (Green3, Greenstate3);
digitalWrite (Green4, Greenstate4);
digitalWrite (Green5, Greenstate5);
digitalWrite (Green6, Greenstate6);
digitalWrite (Blue1, Bluestate1);
digitalWrite (Blue2, Bluestate2);
digitalWrite (Blue3, Bluestate3);
digitalWrite (Blue4, Bluestate4);
digitalWrite (Blue5, Bluestate5);
digitalWrite (Blue6, Bluestate6);
}

```

上記のコードをテストし、以下のArduinoと写真に示す回路にアップロードしました。

[![Arduino%20project](https://global.discourse-cdn.com/digikey/optimized/2X/e/eaf7ad48a16a7fc3dc15c6e76b09365d3512ba39_2_333x250.jpeg)

](https://global.discourse-cdn.com/digikey/original/2X/e/eaf7ad48a16a7fc3dc15c6e76b09365d3512ba39.jpeg "Arduino%20project")

次は、プロジェクトの3Dプリンティングの部品です。

On-Shapeでプロジェクトを描いた後、様々なアイテムの寸法を確認する必要がありました。  
そこで、まず外箱を3Dプリンティングしました。他のパーツは外箱に合わせてサイズを調整します。  
  
外箱

[![IMG_20190327_104554778](https://global.discourse-cdn.com/digikey/optimized/2X/0/0e562fa21233acf9cdf18baba479ec2c9f5430e1_2_333x250.jpeg)

](https://global.discourse-cdn.com/digikey/original/2X/0/0e562fa21233acf9cdf18baba479ec2c9f5430e1.jpeg "IMG\_20190327\_104554778")

インナーライナーの幅や長さを確認するために、ライナーの下側だけをプリンティングしました。  
このパーツは幅がぴったりだったので、フルライナーを3Dプリンティングしました。  
  
インナーライナーの底面テストピース

[![Test-bottom%20of%20inner%20liner](https://global.discourse-cdn.com/digikey/optimized/2X/9/9ff190770d654f3e90d55dc13d8932d9accfa686_2_333x250.jpeg)

](https://global.discourse-cdn.com/digikey/original/2X/9/9ff190770d654f3e90d55dc13d8932d9accfa686.jpeg "Test-bottom%20of%20inner%20liner")

ライナーの幅と長さはきれいに収まりましたが、オブジェクトの角が不規則すぎて、結果的に外箱にうまく収まりませんでした。そこで、インナーライナーを修正しました。

インナーライナー1

[![Inner%20liner%201](https://global.discourse-cdn.com/digikey/optimized/2X/1/1302ea322591a3f250611cf6b7ffc2bd67614470_2_333x250.jpeg)

](https://global.discourse-cdn.com/digikey/original/2X/1/1302ea322591a3f250611cf6b7ffc2bd67614470.jpeg "Inner%20liner%201")

下の写真のように、垂直方向の各コーナーに5mmの面取りを施しました。 これで、ライナーがぴったりとはまるようになりました。

インナーライナー2

[![Inner%20liner%202](https://global.discourse-cdn.com/digikey/optimized/2X/a/a47dc624dbc9d44a78382fa7137b33e52d49e226_2_333x250.jpeg)

](https://global.discourse-cdn.com/digikey/original/2X/a/a47dc624dbc9d44a78382fa7137b33e52d49e226.jpeg "Inner%20liner%202")

その後、蓋を3Dプリンティングしました。これでプロジェクト全体がきれいにまとまりました。

[![Lid](https://global.discourse-cdn.com/digikey/optimized/2X/d/d46f0f5263e143dedba50b5e1d2a52178124ffbf_2_333x250.jpeg)

](https://global.discourse-cdn.com/digikey/original/2X/d/d46f0f5263e143dedba50b5e1d2a52178124ffbf.jpeg "Lid")

下の写真は、arduinoと回路をインナーライナーに装着・配置したものです。

[![Arduino%20and%20circuit%20in%20inner%20liner](https://global.discourse-cdn.com/digikey/optimized/2X/b/b622c0b3ec90a276507bd5852313561ac3b225a9_2_333x250.jpeg)

](https://global.discourse-cdn.com/digikey/original/2X/b/b622c0b3ec90a276507bd5852313561ac3b225a9.jpeg "Arduino%20and%20circuit%20in%20inner%20liner")

下の写真は、組み立てた状態のインナーライナーを外箱に入れたものです。

[![Inner%20liner%20assembled%20in%20outer%20box](https://global.discourse-cdn.com/digikey/optimized/2X/4/4812ed5ec0220d0e9d46264a072c7c26554b3ba7_2_333x250.jpeg)

](https://global.discourse-cdn.com/digikey/original/2X/4/4812ed5ec0220d0e9d46264a072c7c26554b3ba7.jpeg "Inner%20liner%20assembled%20in%20outer%20box")

内部の電源コードが組み立てられて設置されています。

[![image](https://global.discourse-cdn.com/digikey/optimized/2X/b/b9bdeddf8bfb282541b7aa4006c86067ff24d4a2_2_330x250.jpeg)

](https://global.discourse-cdn.com/digikey/original/2X/b/b9bdeddf8bfb282541b7aa4006c86067ff24d4a2.jpeg "image")

完全に組み立てられた箱です！

[![Fully%20assembled%20box](https://global.discourse-cdn.com/digikey/optimized/2X/0/06ec2aa35042122732b804e60c08af9cbbcdeebe_2_333x250.jpeg)

](https://global.discourse-cdn.com/digikey/original/2X/0/06ec2aa35042122732b804e60c08af9cbbcdeebe.jpeg "Fully%20assembled%20box")

以下は、On Shapeのサイトへのリンクで、このプロジェクトをご覧いただけます。  
[https://cad.onshape.com/documents/1f39e195a4a1a2563e7f484d/w/328efc4209ed20ef683577e5/e/7632c65e05b88f4e1808b82c](https://cad.onshape.com/documents/1f39e195a4a1a2563e7f484d/w/328efc4209ed20ef683577e5/e/7632c65e05b88f4e1808b82c)

[Lid.stl](https://forum.digikey.com/uploads/short-url/hYzOFFl2uQZ9rb5tBW9n1un26ZE.stl)（78.0 KB）  
[LED box liner.stl](https://forum.digikey.com/uploads/short-url/b5BpzPP7hl1x9KcNGqC8SVgPt3e.stl) （625.6 KB）  
[Outer box.stl](https://forum.digikey.com/uploads/short-url/r1HAoKaMAy4AnrfJmjIGfyuKFjw.stl) （280.0 KB）

使用した材料  
フィラメント：  
&nbsp;&nbsp;&nbsp;&nbsp;赤 0.112インチPLA （[RM-PL0127](https://www.digikey.jp/product-detail/ja/lulzbot/RM-PL0127/1942-1076-ND/8605435)）  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;外箱の場合（フィラメントが42m）、lulzbotで約21時間かかりました。

&nbsp;&nbsp;&nbsp;&nbsp;白 0.112インチPLA （[RM-PL0128](https://www.digikey.jp/product-detail/ja/lulzbot/RM-PL0128/1942-1077-ND/8605436)）  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;インナーライナーの場合（フィラメントが45.5m）、lulzbotで約18時間かかりました。

&nbsp;&nbsp;&nbsp;&nbsp;黒 0.112インチPLA （[RM-PL0121](https://www.digikey.jp/product-detail/ja/lulzbot/RM-PL0121/1942-1070-ND/8605429)）  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;蓋の部分（フィラメントが10.4m）は、lulzbotで約4時間かかりました。

パネルジャック：2.10mm × 5.50mm（[54-00063](https://www.digikey.jp/product-detail/ja/tensility-international-corp/54-00063/839-1291-ND/6206244)）1個

プラグ：2.10mm × 5.50mm（[10-02225](https://www.digikey.jp/product-detail/ja/tensility-international-corp/10-02225/839-1298-ND/6412240)）付きケーブル 1本

NPNトランジスタ：（[2N3904BU](https://www.digikey.jp/product-detail/ja/onsemi/2N3904BU/2N3904FS-ND/1413)）24個

ワイヤキット：各種サイズ 22AWG 350pcs（[WK-1](https://www.digikey.jp/product-detail/ja/global-specialties/WK-1/BKWK-1-ND/5231340)）1組  
&nbsp;&nbsp;&nbsp;&nbsp;特定の使用  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;100mm 黄色ワイヤ 18本  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;78mm オレンジ色ワイヤ 6本

赤色単線ワイヤ 2本

黒色単線ワイヤ 2本

RGB 4リード・スルーホールLED：（[HV-5RGB25](https://www.digikey.jp/product-detail/ja/inolux/HV-5RGB25/1830-1015-ND/7604615)） 6個

Arduino Mega2560：（[A000067](https://www.digikey.jp/product-detail/ja/arduino/A000067/1050-1018-ND/2639006)）1個

ショートブレッドボード：3.20インチ長さ × 2.00インチ幅（[FIT0096](https://www.digikey.jp/product-detail/ja/dfrobot/FIT0096/1738-1326-ND/7597069)）1個

100Ωスルーホール抵抗 ：6個 すでに持っていたもので、特に品番はありません。しかし、[CFM12JT100R](https://www.digikey.jp/product-detail/ja/stackpole-electronics-inc/CFM12JT100R/S100HCT-ND/2617546)は使えるはずです。

470Ωスルーホール抵抗：（[SFR16S0004700JA500](https://www.digikey.jp/product-detail/ja/vishay-beyschlag-draloric-bc-components/SFR16S0004700JA500/BC4327TB-ND/5065152)） 6個

ネジ：（[1551ATS100](https://www.digikey.jp/product-detail/ja/hammond-manufacturing/1551ATS100/HM1177-ND/460283)） 6個

下図は、回路図です。

[![Glow-Box](https://global.discourse-cdn.com/digikey/original/2X/c/cceaae0bc1f3bdcd0dee09d915ae8dd74996efbb.png)

](https://global.discourse-cdn.com/digikey/original/2X/c/cceaae0bc1f3bdcd0dee09d915ae8dd74996efbb.png "Glow-Box")

プロジェクトをご覧いただきありがとうございます！気に入っていただけましたか？

  
  
  

[オリジナル・ソース（英語）](https://forum.digikey.com/t/a-glowing-box/3182)
