-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenerator_de_culori_RGB_aleatoriu.ino
66 lines (63 loc) · 1.26 KB
/
Generator_de_culori_RGB_aleatoriu.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
int Redpin=11;
int Greenpin=10;
int Bluepin=6;
int RandomNR=0;
int lastRandomNR=0;
void setup() {
pinMode (Redpin, OUTPUT);
pinMode (Greenpin,OUTPUT);
pinMode (Bluepin, OUTPUT);
Serial.begin (9600);
Serial.println ("NR aleatoriu este : ");
randomSeed(33);
}
void loop() {
while (RandomNR==lastRandomNR){
RandomNR=random(4,15);
Serial.println ("X");
}
lastRandomNR=RandomNR;
Serial.println(RandomNR);
RandomNR=random (6,15);
if (RandomNR==6){
SetColor (255,255,0);
delay(1000);
}
if(RandomNR==10) {
SetColor (255,0,255);
delay (1000);
}
if(RandomNR==11) {
SetColor (0,255,255);
delay(1000);
}
if(RandomNR!=6 || RandomNR!=11 || RandomNR!=10 || RandomNR!=22){
SetColor (255,255,255);
delay(1000);
}
if(RandomNR!=6){
Serial.println
("Culoarea nu a fost gasita");
}
if(RandomNR!=11){
Serial.println
("Culoarea nu a fost gasita");
}
if(RandomNR!=10){
Serial.println
("Culoarea nu a fost gasita");
}
if(RandomNR=14){
SetColor (0,190,255);
delay(1000);
if(RandomNR!=22){
Serial.println
("Culoarea nu a fost gasita");
}
}
}
void SetColor (int red, int green, int blue) // the function which sets the color of the RGB LED
{analogWrite (Redpin, red);
analogWrite (Greenpin, green);
analogWrite (Bluepin, blue);
}