-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignal-V2.ino
174 lines (142 loc) · 3.31 KB
/
signal-V2.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#include <FastLED.h>
#define NUM_LEDS1 35
#define Buton 18
#define Buton2 19
#define Buton3 2
int butonDurumu = 0;
volatile int flag1 = 0;
volatile int flag2 = 0;
volatile int flag3 = 0;
CRGB leds1[NUM_LEDS1];
#define led_pini 12
void temizle() {
for (int i = 0; i < NUM_LEDS1; i++) {
leds1[i].setRGB(255, 255, 255);
}
}
void buttonInterrupt(void);
void buttonInterrupt2(void);
void setup() {
Serial.begin(9600);
FastLED.addLeds<WS2812B, led_pini, GRB>(leds1, NUM_LEDS1);
pinMode(Buton, INPUT); // Butonlar için entegre pull-up direnci kullan
pinMode(Buton2, INPUT);
attachInterrupt(digitalPinToInterrupt(Buton), button1change, CHANGE);
attachInterrupt(digitalPinToInterrupt(Buton2), button2change, CHANGE);
attachInterrupt(digitalPinToInterrupt(Buton3), button3change, CHANGE);
randomSeed(analogRead(0));
// Mor (100, 50, 0)
// Turkuvaz (0, 50, 100)
// Sarı (200, 0, 100)
// Pembe (230, 40 ,0)
// #Açık Yeşil (0, 40, 230)
// #Koyu Mor (40, 230, 0)
// Mavi (0, 255, 255)
// Kırmızı (255, 0, 0)
// Yeşil (100, 0, 200)
int a = 0;
int b = 255;
int c = 0;
temizle();
for (int i = 0; i <= 14; i++) {
switch (i % 7) {
case 0:
leds1[14 - i].setRGB(100, 50, 0);
leds1[20 + i].setRGB(100, 50, 100);
FastLED.show();
break;
case 1:
leds1[14 - i].setRGB(0, 50, 100);
leds1[20 + i].setRGB(0, 50, 100);
FastLED.show();
break;
case 2:
leds1[14 - i].setRGB(200, 0, 100);
leds1[20 + i].setRGB(200, 0, 100);
FastLED.show();
break;
case 3:
leds1[14 - i].setRGB(230, 40, 0);
leds1[20 + i].setRGB(230, 40, 0);
FastLED.show();
break;
case 4:
leds1[14 - i].setRGB(40, 230, 0);
leds1[20 + i].setRGB(40, 230, 0);
FastLED.show();
break;
case 5:
leds1[14 - i].setRGB(0, 255, 255);
leds1[20 + i].setRGB(0, 255, 255);
FastLED.show();
break;
case 6:
leds1[14 - i].setRGB(255, 0, 0);
leds1[20 + i].setRGB(255, 0, 0);
FastLED.show();
break;
}
delay(100);
}
}
void button1change() {
if (digitalRead(Buton) == LOW) {
flag1 = 0;
} else {
flag1 = 1;
}
}
void button2change() {
if (digitalRead(Buton2) == LOW) {
flag2 = 0;
} else {
flag2 = 1;
}
}
void button3change() {
if (digitalRead(Buton3) == LOW) {
flag3 = 0;
} else {
flag3 = 1;
}
}
void loop() {
if(flag3) {
for (int i = 0; i < 35; i++) {
leds1[i].setRGB(255,0,0);
}
FastLED.show();
}
if (flag1 && !flag2 && !flag3) {
temizle();
for (int i = 0; i <= 14; i++) {
leds1[14 - i].setRGB(255, 0, 80);
FastLED.show();
delay(70);
}
}
if (flag2 && !flag1 && !flag3) {
temizle();
for (int i = 20; i < NUM_LEDS1; i++) {
leds1[i].setRGB(255, 0, 80);
FastLED.show();
delay(70);
}
}
if (flag1 && flag2 && !flag3) {
temizle();
for (int i = 0; i <= 14; i++) {
leds1[14 - i].setRGB(255, 0, 80);
leds1[20 + i].setRGB(255, 0, 80);
FastLED.show();
delay(70);
}
}
if (!flag1 && !flag2 && !flag3) {
temizle();
FastLED.show();
}
Serial.print("Random sayi: ");
Serial.println(random(256));
delay(100);
}