質問編集履歴
7
内容変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,26 +1,17 @@
|
|
1
1
|
### 前提・実現したいこと
|
2
|
-
一本のテープLEDを複数のタクトスイッチでそれぞれ違う光らせ方をやりたい
|
2
|
+
一本のテープLEDを複数のタクトスイッチでそれぞれ違う光らせ方をやりたい
|
3
3
|
|
4
|
-
ここに質問の内容を詳しく書いてください。
|
5
|
-
(例)PHP(CakePHP)で●●なシステムを作っています。
|
6
|
-
■■な機能を実装中に以下のエラーメッセージが発生しました。
|
7
|
-
|
8
4
|
### 発生している問題・エラーメッセージ
|
9
5
|
一つのタクトスイッチを何回も押してそれぞれ違う光らせ方はできますが、複数のタクトスイッチにそれぞれの光らせ方を入れるのができません。
|
10
6
|
使っているテープLEDはWS2812B 一本です。
|
11
|
-
```
|
12
|
-
エラーメッセージ
|
13
|
-
```
|
14
7
|
|
8
|
+
|
15
9
|
### 該当のソースコード__イタリックテキスト__
|
16
10
|
|
17
|
-
```ここに言語名を入力
|
18
|
-
ソースコード
|
19
11
|
|
20
|
-
```
|
21
12
|
|
22
|
-
### 試したこと
|
23
13
|
|
14
|
+
|
24
15
|
ここに問題に対して試したことを記載してください。
|
25
16
|
|
26
17
|
スケッチ例から光り方は持ってきました。
|
6
回答を元に変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -29,9 +29,9 @@
|
|
29
29
|
|
30
30
|
```Arduino```
|
31
31
|
const int switchPin = 2;
|
32
|
-
const int
|
32
|
+
const int switchpinpin=3;
|
33
33
|
|
34
|
-
#define NUM_LEDS 144
|
34
|
+
#define NUM_LEDS 144
|
35
35
|
#include "FastLED.h"
|
36
36
|
#define DATA_PIN 6
|
37
37
|
#define CLOCK_PIN 13
|
@@ -42,79 +42,75 @@
|
|
42
42
|
|
43
43
|
//
|
44
44
|
void setup () {
|
45
|
-
pinMode(switchPin, INPUT);
|
45
|
+
pinMode(switchPin, INPUT);
|
46
|
-
pinMode(
|
46
|
+
pinMode(switchpinpin,INPUT);
|
47
|
-
Serial.begin(57600);
|
47
|
+
Serial.begin(57600);
|
48
|
-
Serial.println("resetting");
|
48
|
+
Serial.println("resetting");
|
49
|
-
LEDS.addLeds<WS2812,DATA_PIN,RGB>(leds,NUM_LEDS);
|
49
|
+
LEDS.addLeds<WS2812,DATA_PIN,RGB>(leds,NUM_LEDS);
|
50
|
-
LEDS.setBrightness(100);
|
50
|
+
LEDS.setBrightness(100);
|
51
51
|
}
|
52
52
|
void fadeall() { for(int i = 0; i < NUM_LEDS; i++) { leds[i].nscale8(250); } }
|
53
53
|
|
54
54
|
|
55
55
|
//
|
56
56
|
void loop () {
|
57
|
-
if (
|
57
|
+
if (HIGH, switchPin) {
|
58
|
-
}
|
59
|
-
|
60
58
|
static uint8_t hue = 0;
|
61
|
-
Serial.print("x");
|
59
|
+
Serial.print("x");
|
62
|
-
for(int i = 0; i < NUM_LEDS; i++) {
|
60
|
+
for(int i = 0; i < NUM_LEDS; i++) {
|
63
|
-
leds[i] = CHSV(hue++, 255, 255);
|
61
|
+
leds[i] = CHSV(hue++, 255, 255);
|
64
|
-
FastLED.show();
|
62
|
+
FastLED.show();
|
65
|
-
fadeall();
|
63
|
+
fadeall();
|
66
|
-
delay(10);
|
64
|
+
delay(10);
|
67
|
-
}
|
65
|
+
}
|
68
|
-
Serial.print("x");
|
66
|
+
Serial.print("x");
|
67
|
+
|
68
|
+
for(int i = (NUM_LEDS)-1; i >= 0; i--) {
|
69
|
+
leds[i] = CHSV(hue++, 255, 255);
|
70
|
+
FastLED.show();
|
71
|
+
fadeall();
|
72
|
+
delay(10);
|
73
|
+
}
|
69
74
|
|
75
|
+
time = micros();
|
76
|
+
Serial.println(time);
|
77
|
+
delay(1); // 1秒おきに送信
|
78
|
+
for (int i = 0; i < NUM_LEDS; i++) {
|
79
|
+
leds[i] = CRGB( 0, 0, 0);
|
80
|
+
FastLED.show();
|
81
|
+
delay(1);
|
82
|
+
}
|
83
|
+
}
|
84
|
+
if (HIGH,switchpinpin) {
|
85
|
+
static uint8_t hue = 0;
|
86
|
+
Serial.print("x");
|
87
|
+
for(int i = 0; i < NUM_LEDS; i++) {
|
88
|
+
leds[i] = CHSV(hue++, 255, 255);
|
89
|
+
FastLED.show();
|
90
|
+
fadeall();
|
91
|
+
delay(100);
|
92
|
+
}
|
70
|
-
for(int i = (NUM_LEDS)-1; i >= 0; i--) {
|
93
|
+
for(int i = (NUM_LEDS)-1; i >= 0; i--) {
|
71
|
-
leds[i] = CHSV(hue++, 255, 255);
|
94
|
+
leds[i] = CHSV(hue++, 255, 255);
|
72
|
-
FastLED.show();
|
95
|
+
FastLED.show();
|
73
|
-
fadeall();
|
96
|
+
fadeall();
|
74
|
-
delay(
|
97
|
+
delay(100);
|
75
|
-
}
|
98
|
+
}
|
99
|
+
|
76
100
|
|
77
|
-
time = micros();
|
78
|
-
Serial.println(time);
|
79
|
-
delay(1); // 1秒おきに送信
|
80
|
-
for (int i = 0; i < NUM_LEDS; i++) {
|
81
|
-
leds[i] = CRGB( 0, 0, 0);
|
82
|
-
FastLED.show();
|
83
|
-
delay(1);
|
84
|
-
}
|
85
101
|
|
102
|
+
time = micros();
|
103
|
+
Serial.println(time);
|
104
|
+
delay(1); // 1秒おきに送信
|
86
|
-
|
105
|
+
for (int i = 0; i < NUM_LEDS; i++) {
|
106
|
+
leds[i] = CRGB( 0, 0, 0);
|
107
|
+
FastLED.show();
|
108
|
+
delay(1);
|
87
|
-
}
|
109
|
+
}
|
110
|
+
}
|
88
111
|
|
89
112
|
|
90
|
-
Serial.print("x");
|
91
|
-
for(int i = 0; i < NUM_LEDS; i++) {
|
92
|
-
leds[i] = CHSV(hue++, 255, 255);
|
93
|
-
FastLED.show();
|
94
|
-
fadeall();
|
95
|
-
delay(100);
|
96
113
|
}
|
97
|
-
|
98
|
-
for(int i = (NUM_LEDS)-1; i >= 0; i--) {
|
99
|
-
leds[i] = CHSV(hue++, 255, 255);
|
100
|
-
FastLED.show();
|
101
|
-
fadeall();
|
102
|
-
delay(100);
|
103
|
-
}
|
104
|
-
|
105
|
-
|
106
|
-
time = micros();
|
107
|
-
Serial.println(time);
|
108
|
-
delay(1); // 1秒おきに送信
|
109
|
-
for (int i = 0; i < NUM_LEDS; i++) {
|
110
|
-
leds[i] = CRGB( 0, 0, 0);
|
111
|
-
FastLED.show();
|
112
|
-
delay(1);
|
113
|
-
}
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
}
|
118
114
|
```
|
119
115
|
### 補足情報(FW/ツールのバージョンなど)
|
120
116
|
|
5
回答を元に変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -27,6 +27,7 @@
|
|
27
27
|
光った後にテープを全部消すやり方が分からず、
|
28
28
|
無理やりつけたようなものがついています。すいません。
|
29
29
|
|
30
|
+
```Arduino```
|
30
31
|
const int switchPin = 2;
|
31
32
|
const int switchPinPin=3;
|
32
33
|
|
@@ -53,7 +54,7 @@
|
|
53
54
|
|
54
55
|
//
|
55
56
|
void loop () {
|
56
|
-
|
57
|
+
if (digitalRead(switchPin) == HIGH) {
|
57
58
|
}
|
58
59
|
|
59
60
|
static uint8_t hue = 0;
|
@@ -82,7 +83,7 @@
|
|
82
83
|
delay(1);
|
83
84
|
}
|
84
85
|
|
85
|
-
|
86
|
+
if (digitalRead(switchPinPin) == HIGH) {
|
86
87
|
}
|
87
88
|
|
88
89
|
|
@@ -114,6 +115,7 @@
|
|
114
115
|
|
115
116
|
|
116
117
|
}
|
118
|
+
```
|
117
119
|
### 補足情報(FW/ツールのバージョンなど)
|
118
120
|
|
119
121
|
ここにより詳細な情報を記載してください。
|
4
ソースコード消去
title
CHANGED
File without changes
|
body
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
|
17
17
|
```ここに言語名を入力
|
18
18
|
ソースコード
|
19
|
-
|
19
|
+
|
20
20
|
```
|
21
21
|
|
22
22
|
### 試したこと
|
3
タグ消去
title
CHANGED
File without changes
|
body
CHANGED
File without changes
|
2
タグ消去
title
CHANGED
File without changes
|
body
CHANGED
File without changes
|
1
スケッチを入れました
title
CHANGED
File without changes
|
body
CHANGED
@@ -23,6 +23,97 @@
|
|
23
23
|
|
24
24
|
ここに問題に対して試したことを記載してください。
|
25
25
|
|
26
|
+
スケッチ例から光り方は持ってきました。
|
27
|
+
光った後にテープを全部消すやり方が分からず、
|
28
|
+
無理やりつけたようなものがついています。すいません。
|
29
|
+
|
30
|
+
const int switchPin = 2;
|
31
|
+
const int switchPinPin=3;
|
32
|
+
|
33
|
+
#define NUM_LEDS 144
|
34
|
+
#include "FastLED.h"
|
35
|
+
#define DATA_PIN 6
|
36
|
+
#define CLOCK_PIN 13
|
37
|
+
CRGB leds[NUM_LEDS];
|
38
|
+
|
39
|
+
unsigned long time;
|
40
|
+
|
41
|
+
|
42
|
+
//
|
43
|
+
void setup () {
|
44
|
+
pinMode(switchPin, INPUT);
|
45
|
+
pinMode(switchPinPin,INPUT);
|
46
|
+
Serial.begin(57600);
|
47
|
+
Serial.println("resetting");
|
48
|
+
LEDS.addLeds<WS2812,DATA_PIN,RGB>(leds,NUM_LEDS);
|
49
|
+
LEDS.setBrightness(100);
|
50
|
+
}
|
51
|
+
void fadeall() { for(int i = 0; i < NUM_LEDS; i++) { leds[i].nscale8(250); } }
|
52
|
+
|
53
|
+
|
54
|
+
//
|
55
|
+
void loop () {
|
56
|
+
while (digitalRead(switchPin) == LOW) {
|
57
|
+
}
|
58
|
+
|
59
|
+
static uint8_t hue = 0;
|
60
|
+
Serial.print("x");
|
61
|
+
for(int i = 0; i < NUM_LEDS; i++) {
|
62
|
+
leds[i] = CHSV(hue++, 255, 255);
|
63
|
+
FastLED.show();
|
64
|
+
fadeall();
|
65
|
+
delay(10);
|
66
|
+
}
|
67
|
+
Serial.print("x");
|
68
|
+
|
69
|
+
for(int i = (NUM_LEDS)-1; i >= 0; i--) {
|
70
|
+
leds[i] = CHSV(hue++, 255, 255);
|
71
|
+
FastLED.show();
|
72
|
+
fadeall();
|
73
|
+
delay(10);
|
74
|
+
}
|
75
|
+
|
76
|
+
time = micros();
|
77
|
+
Serial.println(time);
|
78
|
+
delay(1); // 1秒おきに送信
|
79
|
+
for (int i = 0; i < NUM_LEDS; i++) {
|
80
|
+
leds[i] = CRGB( 0, 0, 0);
|
81
|
+
FastLED.show();
|
82
|
+
delay(1);
|
83
|
+
}
|
84
|
+
|
85
|
+
while (digitalRead(switchPinPin) == LOW) {
|
86
|
+
}
|
87
|
+
|
88
|
+
|
89
|
+
Serial.print("x");
|
90
|
+
for(int i = 0; i < NUM_LEDS; i++) {
|
91
|
+
leds[i] = CHSV(hue++, 255, 255);
|
92
|
+
FastLED.show();
|
93
|
+
fadeall();
|
94
|
+
delay(100);
|
95
|
+
}
|
96
|
+
|
97
|
+
for(int i = (NUM_LEDS)-1; i >= 0; i--) {
|
98
|
+
leds[i] = CHSV(hue++, 255, 255);
|
99
|
+
FastLED.show();
|
100
|
+
fadeall();
|
101
|
+
delay(100);
|
102
|
+
}
|
103
|
+
|
104
|
+
|
105
|
+
time = micros();
|
106
|
+
Serial.println(time);
|
107
|
+
delay(1); // 1秒おきに送信
|
108
|
+
for (int i = 0; i < NUM_LEDS; i++) {
|
109
|
+
leds[i] = CRGB( 0, 0, 0);
|
110
|
+
FastLED.show();
|
111
|
+
delay(1);
|
112
|
+
}
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
}
|
26
117
|
### 補足情報(FW/ツールのバージョンなど)
|
27
118
|
|
28
119
|
ここにより詳細な情報を記載してください。
|