Materialele folosite pentru acest mic proiect sint urmatoarele.
- Cablu UTP vechi pe care l-am recuperat din vechea retea locala a casei.
- 12 siruri a 8 leduri pe sir, care inseamna 8x12 leduri RGB, cumparate de pe aliexpress. 100 de bucati cumparate la
- Un arduino Nano, dar acesta in functie de timpul liber am sa-l inlociesc cu un mega, probabil intre sarbatori sau dupa, pana atunci nu o sa am timp de nimic.
- Alimentare de 5V pentru Arduino
- 12 x bucati IRF530N tranzistori mosfet, 20 de bucat cumparate la
- o placa de prototipare fara cositorire, (breadboard) acesta va fi inlocuit cu un pcb universal, i-l folosesc doar pana fac versiunea finala
- 12 bucati rezistoare de 680 ohmi, 100 de bucati cumparate la
- 2 bucati placa prototipare 2x8 cm, modelul care se cositoreste, momentan folosit doar 1 bucata pentru mosfeti, cealalta va inlocui breadboardul
- 6 bucati capete terminale cu 2 poli, 20 de bucati cumparate la
Codul care se incarca in Arduino via arduino IDE este urmatorul:
Code: Select all
//String 1
#define pinR1 11
#define pinG1 10
#define pinB1 9
//String 2
#define pinR2 6
#define pinG2 5
#define pinB2 3
//String 3
#define pinR3 A0
#define pinG3 A1
#define pinB3 A2
//String 4
#define pinR4 A3
#define pinG4 A4
#define pinB4 A5
void setup() {
pinMode(pinR1, OUTPUT);
pinMode(pinG1, OUTPUT);
pinMode(pinB1, OUTPUT);
pinMode(pinR2, OUTPUT);
pinMode(pinG2, OUTPUT);
pinMode(pinB2, OUTPUT);
pinMode(pinR3, OUTPUT);
pinMode(pinG3, OUTPUT);
pinMode(pinB3, OUTPUT);
pinMode(pinR4, OUTPUT);
pinMode(pinG4, OUTPUT);
pinMode(pinB4, OUTPUT);
}
void loop()
{
Anim1(150,15);
Anim2(200,40);
Anim3(250,40);
Anim4(200,40);
Anim5(250,20);
Anim6(3,3);
Anim7(5,1);
}
void Anim1(int wait, int durata)
{
for(int d = 1; d < durata; d++)
{
for(int r = 1; r <= 4; r++)
{
Led(r,255,0,0);
delay(wait);
Led(r,0,0,0);
}
}
for(int d = 1; d <= durata; d++)
{
for(int r = 1; r <= 4; r++)
{
Led(r,0,255,0);
delay(wait);
Led(r,0,0,0);
}
}
for(int d = 1; d <= durata; d++)
{
for(int r = 1; r <= 4; r++)
{
Led(r,0,0,255);
delay(wait);
Led(r,0,0,0);
}
}
for(int d = 1; d <= durata; d++)
{
for(int r = 1; r <= 4; r++)
{
Led(r,255,0,255);
delay(wait);
Led(r,0,0,0);
}
}
for(int d = 1; d <= durata; d++)
{
for(int r = 1; r <= 4; r++)
{
Led(r,0,255,255);
delay(wait);
Led(r,0,0,0);
}
}
for(int d = 1; d <= durata; d++)
{
for(int r = 1; r <= 4; r++)
{
Led(r,255,255,0);
delay(wait);
Led(r,0,0,0);
}
}
for(int d = 1; d <= durata; d++)
{
for(int r = 1; r <= 4; r++)
{
Led(r,255,255,255);
delay(wait);
Led(r,0,0,0);
}
}
}
void Anim2(int wait, int rep)
{
for(int i = 0; i < rep; i++)
{
int str = rand() % 5;
int r = rand() % 256;
int g = rand() % 256;
int b = rand() % 256;
Led(str, r, g, b);
delay(wait);
}
}
void Anim3(int wait, int rep)
{
for(int i = 0; i < rep; i++)
{
int str = rand() % 5;
int r = rand() % 256;
int g = rand() % 256;
int b = rand() % 256;
Led(1, r, g, b);
Led(2, r, g, b);
Led(3, r, g, b);
Led(4, r, g, b);
delay(wait);
}
}
void Anim4(int wait, int durata)
{
int comparator;
int comparator2;
int comparator3;
for(int d = 1; d < durata; d++)
{
for(int r = 1; r <= 4; r++)
{
Led(r,255,0,0);
comparator = r-1;
if (comparator < 1) comparator = comparator + 4;
Led(comparator,0,255,0);
comparator2 = r-2;
if (comparator2 < 1) comparator2 = comparator2 + 4;
Led(comparator2,0,0,255);
comparator3 = r-3;
if (comparator3 < 1) comparator3 = comparator3 + 4;
Led(comparator3,255,255,255);
delay(wait);
Led(r,0,0,0);
}
}
}
void Anim5(int wait, int durata)
{
int comparator;
int comparator2;
int comparator3;
for(int d = 1; d < durata; d++)
{
for(int r = 1; r <= 4; r++)
{
Led(r,255,0,0);
comparator = r-1;
if (comparator < 1) comparator = comparator + 4;
Led(comparator,255,0,0);
comparator2 = r-2;
if (comparator2 < 1) comparator2 = comparator2 + 4;
Led(comparator2,0,0,255);
comparator3 = r-3;
if (comparator3 < 1) comparator3 = comparator3 + 4;
Led(comparator3,0,0,255);
delay(wait);
Led(r,0,0,0);
delay(wait);
}
}
}
void Anim6(int wait, int durata)
{
Led(1,0,0,0);
Led(2,0,0,0);
Led(3,0,0,0);
Led(4,0,0,0);
for(int d = 0; d < durata; d++)
{
int x = 1;
for (int i = 0; i > -1; i = i + x)
{
Led(1,i,0,0);
Led(2,i,0,0);
if (i == 255) x = -1;
delay(wait);
}
}
for(int d = 0; d < durata; d++)
{
int x = 1;
for (int i = 0; i > -1; i = i + x)
{
Led(1,0,i,0);
Led(2,0,i,0);
if (i == 255) x = -1;
delay(wait);
}
}
for(int d = 0; d < durata; d++)
{
int x = 1;
for (int i = 0; i > -1; i = i + x)
{
Led(1,0,0,i);
Led(2,0,0,i);
if (i == 255) x = -1;
delay(wait);
}
}
for(int d = 0; d < durata; d++)
{
int x = 1;
for (int i = 0; i > -1; i = i + x)
{
Led(1,i,0,i);
Led(2,i,0,i);
if (i == 255) x = -1;
delay(wait);
}
}
for(int d = 0; d < durata; d++)
{
int x = 1;
for (int i = 0; i > -1; i = i + x)
{
Led(1,i,i,0);
Led(2,i,i,0);
if (i == 255) x = -1;
delay(wait);
}
}
for(int d = 0; d < durata; d++)
{
int x = 1;
for (int i = 0; i > -1; i = i + x)
{
Led(1,i,i,i);
Led(2,i,i,i);
if (i == 255) x = -1;
delay(wait);
}
}
}
void Anim7(int wait, int durata)
{
Led(1,0,0,0);
Led(2,0,0,0);
Led(3,0,0,0);
Led(4,0,0,0);
for(int d = 0; d < durata; d++)
{
int x = 1;
for (int i = 0; i > -1; i = i + x)
{
Led(1,i,0,0);
Led(2,i,0,0);
Led(3,i,0,0);
Led(4,i,0,0);
if (i == 255) x = -1;
delay(wait);
}
}
for(int d = 0; d < durata; d++)
{
int x = 1;
for (int i = 0; i > -1; i = i + x)
{
Led(1,0,i,0);
Led(2,0,i,0);
Led(3,0,i,0);
Led(4,0,i,0);
if (i == 255) x = -1;
delay(wait);
}
}
for(int d = 0; d < durata; d++)
{
int x = 1;
for (int i = 0; i > -1; i = i + x)
{
Led(1,0,0,i);
Led(2,0,0,i);
Led(3,0,0,i);
Led(4,0,0,i);
if (i == 255) x = -1;
delay(wait);
}
}
for(int d = 0; d < durata; d++)
{
int x = 1;
for (int i = 0; i > -1; i = i + x)
{
Led(1,i,0,i);
Led(2,i,0,i);
Led(3,255,0,i);
Led(4,255,0,i);
if (i == 255) x = -1;
delay(wait);
}
}
for(int d = 0; d < durata; d++)
{
int x = 1;
for (int i = 0; i > -1; i = i + x)
{
Led(1,i,i,0);
Led(2,i,i,0);
Led(3,i,i,0);
Led(4,i,i,0);
if (i == 255) x = -1;
delay(wait);
}
}
for(int d = 0; d < durata; d++)
{
int x = 1;
for (int i = 0; i > -1; i = i + x)
{
Led(1,i,i,i);
Led(2,i,i,i);
Led(3,i,i,i);
Led(4,i,i,i);
if (i == 255) x = -1;
delay(wait);
}
}
}
void Led(int Number, int Red, int Green, int Blue)
{
if(Number == 1)
{
analogWrite(pinR1, Red);
analogWrite(pinG1, Green);
analogWrite(pinB1, Blue);
}
if(Number == 2)
{
analogWrite(pinR2, Red);
analogWrite(pinG2, Green);
analogWrite(pinB2, Blue);
}
if(Number == 3)
{
analogWrite(pinR3, Red);
analogWrite(pinG3, Green);
analogWrite(pinB3, Blue);
}
if(Number == 4)
{
analogWrite(pinR4, Red);
analogWrite(pinG4, Green);
analogWrite(pinB4, Blue);
}
}
si pleaca de la BLINK LED, doar ca a fost putin mai adaugat, pentru a avea diverse animatii cu cele 12 siruri.
Schemele sirurilor, si legaturile la Arduino le puteti vedea in aceasta schema
Iar schema bloc a sirurilor este cea din imaginea urmatoare
In momentul in care o sa schimb microcontrolerul si rescriu codul, o sa revin cu detalii.
Spor la bricolat !