ArduShop.ro

ArduShop.ro
cod Z4A413ZN reducere 5%, pentru vizitatorii paginilor mele !

marți, 7 aprilie 2015

Joc de lumini (lumina dinamica) cu 10 canale

   Un mod de a realiza o un joc de lumini sau lumina dinamica cu un numar de canale, in afara de a utiliza o simpla memorie (E)EPROM este acela in care se foloseste un microcontrolor sau o placa de dezvoltare.
   Am folosit o placa de dezvoltare Arduino Nano, care era libera, dar se poate folosi, fara modificari, orice placa Arduino (Uno, Mega, Micro, Due, etc).
   Schema folosita de mine este:
iar montajul:
 
   La inceput am folosit un sistem simple de comanda directa a iesirilor, dar pentru a putea realiza jocuri complexe cu combinatii, am folosit siruri/matrici dupa cum este prezentat in articolul de la http://arduino.cc/en/reference/array, dar am folosit si informatii de la Matrice 8x8 - www.roroid.ro.
   Experimente sunt prezentate in mai multe filmulete:
- joc de lumini 10 canale
- joc lumini 10 canale (2)
- joc lumini 10 canale (6)
   Sketch-ul (mai) elaborat este:
/*
info from
http://arduino.cc/en/Tutorial/Array  - Arrays
http://www.roroid.ro/matrice-8x8/  
original sketch ver.3b by niq_ro - http://www.tehnic.go.ro
http://nicuflorica.blogspot.ro/
http://arduinotehniq.blogspot.com/
*/

int timer = 135;           // timp intre tranzitii/miscari
int ledPins[] = { 
  2, 3, 4, 5, 6, 7, 8, 9, 10, 11};       // pinii digitali folositi
int pinCount = 10;           // numar de pini/iesiri

int jocx[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};  // matricea 
int joc[12] = {
0,   // toate stinse
1,   // primul aprins
2,   // al doilea aprins
4,   // al treilea aprins
8,   // al patrulea aprins
16,  // al cincilea aprins
32,  // al saselea aprins
64,  // al saptelea aprins
128, // al optulea aprins
256, // al noualea aprins
512, // al zecelea aprins
1023 // toate 10 aprinse
};
int joc2[12] = {1023, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0};
int joc3[20] = {0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 513, 514, 516, 520, 528, 544, 576, 640, 768}; 
int joc4[20] = {769, 770, 772, 776, 784, 800, 832, 896, 897, 898, 900, 904, 912, 928, 960,
961, 962, 964, 968, 976};
int joc4a[16] = {992, 993, 994, 996, 1000, 1008, 1009, 1010, 1012,
1016, 1017, 1018, 1020, 1021, 1022, 1023};
int joc10[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
int joc11[10] = {3, 6, 12, 24, 48, 96, 192, 384, 768, 513};
int joc12[10] = {7, 14, 28, 56, 112, 224, 448, 896, 769, 515};
int joc13[10] = {15, 30, 60, 120, 240, 480, 960, 897, 771, 519};
int joc14[10] = {31, 62, 124, 248, 496, 992, 961, 899, 775, 527};


void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  // the array elements are numbered from 0 to (pinCount - 1).
  // use a for loop to initialize each pin as an output:
  for (int thisPin = 0; thisPin < pinCount; thisPin++)  {
    pinMode(ledPins[thisPin], OUTPUT);      
  }
}

void loop() {

for (byte w2 = 1; w2 < 4; w2++) { 
 Serial.print("w=");
 Serial.println(w2);
 Serial.print("timer=");
 Serial.print(timer);
 Serial.println("ms"); 


for (byte z1 = 0; z1 < 12; z1++) {
jocx[z1]=joc2[z1];
}
joace(12);

for (byte z1 = 0; z1 < 12; z1++) {
jocx[z1]=joc[z1];
}
joace(12);

for (byte z1 = 0; z1 < 20; z1++) {
jocx[z1]=joc3[z1];
}
joace(20);

for (byte z1 = 0; z1 < 20; z1++) {
jocx[z1]=joc4[z1];
}
joace(20);

for (byte z1 = 0; z1 < 16; z1++) {
jocx[z1]=joc4a[z1];
}
joace(16);


delay(timer);

// incerc invers
for (byte z1 = 0; z1 < 16; z1++) {
jocx[z1]=joc4a[15-z1];
}
joace(16);
//delay(timer);

for (byte z1 = 0; z1 < 20; z1++) {
jocx[z1]=joc4[19-z1];
}
joace(20);
//delay(timer);

for (byte z1 = 0; z1 < 20; z1++) {
jocx[z1]=joc3[19-z1];
}
joace(20);

// alte jocuri
for (byte w = 1; w < 6; w++) { 
for (byte z1 = 0; z1 < 10; z1++) {
jocx[z1]=joc10[z1];
}
joace(10);
}

for (byte w = 1; w < 6; w++) { 
for (byte z1 = 0; z1 < 10; z1++) {
jocx[z1]=joc11[z1];
}
joace(10);
}

for (byte w = 1; w < 6; w++) { 
for (byte z1 = 0; z1 < 10; z1++) {
jocx[z1]=joc12[z1];
}
joace(10);
}

for (byte w = 1; w < 6; w++) { 
for (byte z1 = 0; z1 < 10; z1++) {
jocx[z1]=joc13[z1];
}
joace(10);
}

for (byte w = 1; w < 6; w++) { 
for (byte z1 = 0; z1 < 10; z1++) {
jocx[z1]=joc14[z1];
}
joace(10);
}

// invers acum
//delay(timer);


for (byte w = 1; w < 6; w++) { 
for (byte z1 = 0; z1 < 10; z1++) {
jocx[z1]=joc14[9-z1];
}
joace(10);
}


for (byte w = 1; w < 6; w++) { 
for (byte z1 = 0; z1 < 10; z1++) {
jocx[z1]=joc13[9-z1];
}
joace(10);
}

for (byte w = 1; w < 6; w++) { 
for (byte z1 = 0; z1 < 10; z1++) {
jocx[z1]=joc12[9-z1];
}
joace(10);
}

for (byte w = 1; w < 6; w++) { 
for (byte z1 = 0; z1 < 10; z1++) {
jocx[z1]=joc11[9-z1];
}
joace(10);
}

for (byte w = 1; w < 6; w++) { 
for (byte z1 = 0; z1 < 10; z1++) {
jocx[z1]=joc10[9-z1];
}
joace(10);
delay(timer);
}

delay(timer);

timer = timer / 1.5;
}
timer = timer * 1.5*1.5*1.5;
}


 
void joace(byte z1)
{
// primul lot
Serial.println("joc1 - ");
for (byte z = 0; z < z1; z++) {
Serial.println(jocx[z]);

int z1 = jocx[z]/512;
//Serial.print("z1 = ");
Serial.print(z1);
int rz1 = jocx[z] - 512*z1;

int z2 = rz1/256;
//Serial.print("  z2 = ");
Serial.print(z2);
int rz2 = rz1 - 256*z2;

int z3 = rz2/128;
//Serial.print("  z3 = ");
Serial.print(z3);
int rz3 = rz2 - 128*z3;

int z4 = rz3/64;
//Serial.print("  z4 = ");
Serial.print(z4);
int rz4 = rz3 - 64*z4;

int z5 = rz4/32;
//Serial.print("  z5 = ");
Serial.print(z5);
int rz5 = rz4 - 32*z5;

int z6 = rz5/16;
//Serial.print("  z6 = ");
Serial.print(z6);
int rz6 = rz5 - 16*z6;

int z7 = rz6/8;
//Serial.print("  z7 = ");
Serial.print(z7);
int rz7 = rz6 - 8*z7;

int z8 = rz7/4;
//Serial.print("  z8 = ");
Serial.print(z8);
int rz8 = rz7 - 4*z8;

int z9 = rz8/2;
//Serial.print("  z9 = ");
Serial.print(z9);
int z10 = rz8 - 2*z9;

//Serial.print("  z10 = ");
Serial.println(z10);


if (z1 == 1) digitalWrite(ledPins[0], HIGH);
else digitalWrite(ledPins[0], LOW); 
if (z2 == 1) digitalWrite(ledPins[1], HIGH);
else digitalWrite(ledPins[1], LOW); 
if (z3 == 1) digitalWrite(ledPins[2], HIGH);
else digitalWrite(ledPins[2], LOW); 
if (z4 == 1) digitalWrite(ledPins[3], HIGH);
else digitalWrite(ledPins[3], LOW);
if (z5 == 1) digitalWrite(ledPins[4], HIGH);
else digitalWrite(ledPins[4], LOW); 
if (z6 == 1) digitalWrite(ledPins[5], HIGH);
else digitalWrite(ledPins[5], LOW); 
if (z7 == 1) digitalWrite(ledPins[6], HIGH);
else digitalWrite(ledPins[6], LOW); 
if (z8 == 1) digitalWrite(ledPins[7], HIGH);
else digitalWrite(ledPins[7], LOW); 
if (z9 == 1) digitalWrite(ledPins[8], HIGH);
else digitalWrite(ledPins[8], LOW); 
if (z10 == 1) digitalWrite(ledPins[9], HIGH);
else digitalWrite(ledPins[9], LOW); 
  
delay(timer);

 Serial.println("********************");
}
}
   Pentru versiunea asta de sketch am facut filmuletul joc lumini 10 canale (7):
8.03.2015
   Dupa ce am constatat ca sketch-ul meu ocupa spatiu si memorie multa, desi jocurile de lumini nu-s asa complexe:
am cerut ajutorul lui Gabi (http://www.profytec.com/ & http://www.rotulosconled.com/), care mi-a dat un mic exemplu care comanda direct porturile B si D ale microcontroleului de pe placa de dezvoltare. Pentru a intelege sketch-ul, care-l voi posta vedeti materialul de la http://arduino.cc/en/Hacking/PinMapping168):
   Pentru un program similar, am acum
  Sketch-ul adaptat de mine este:
// LUMINA DINAMICA By Gabriel Neagu //
// http://www.profytec.com/
// http://www.rotulosconled.com/
////// PORTUL B / PORTUL D//////
///    00001111   11111100   ///
///////////9876   543210////////
// sketch complet de Nicu FLORICA (niq_ro)
// http://www.tehnic.go.ro
// http://nicuflorica.blogspot.ro/
// http://arduinotehniq.blogspot.com/

int t=100;
void setup() 
{
  DDRD = DDRD | B11111100; // Seteaza portul D ca iesiri unde e valoare 1 
  DDRB = DDRB | B00001111; // Seteaza portul B ca iesiri unde e valoare 1 
  for (int a=2; a<=11; a++) { pinMode(a, OUTPUT);} // Activeaza iesirile de la 2 la 11 (digitalPin)
}

void loop() 
{
// toate stinse
PORTB = B00000000; PORTD = B00000000;
delay(t);  

// un led se deplaseaza de la stanga la dreapta
unledstdr();  

// toate stinse
PORTB = B00000000; PORTD = B00000000;
delay(t);

// 2 leduri se deplaseaza de la stanga la dreapta
doiledstdr();

// toate stinse
PORTB = B00000000; PORTD = B00000000;
delay(t);

// 3 leduri se deplaseaza de la stanga la dreapta
treiledstdr();

// toate stinse
PORTB = B00000000; PORTD = B00000000;
delay(t);

// 4 leduri se deplaseaza de la stanga la dreapta
patruledstdr();

// toate stinse
PORTB = B00000000; PORTD = B00000000;
delay(t);

// joc de umplere de la stanga
umplst();
delay(5*t);
// joc de golire spre stanga
golst();
delay(5*t);
// joc de umplere de la stanga
umplst();
delay(5*t);
// joc de golire spre dreapta
goldr();
delay(t);

// gata programul principal, acum reia bucla
}

// incep subrutinele...
void umplst() {
// joc de umplere de la stanga
PORTB = B00001000; PORTD = B00000000;
delay(t);
PORTB = B00000100; PORTD = B00000000;
delay(t);
PORTB = B00000010; PORTD = B00000000;
delay(t);
PORTB = B00000001; PORTD = B00000000;
delay(t);
PORTB = B00000000; PORTD = B10000000;
delay(t);
PORTB = B00000000; PORTD = B01000000;
delay(t);
PORTB = B00000000; PORTD = B00100000;
delay(t);
PORTB = B00000000; PORTD = B00010000;
delay(t);
PORTB = B00000000; PORTD = B00001000;
delay(t);
PORTB = B00000000; PORTD = B00000100;
delay(t);
PORTB = B00001000; PORTD = B00000100;
delay(t);
PORTB = B00000100; PORTD = B00000100;
delay(t);
PORTB = B00000010; PORTD = B00000100;
delay(t);
PORTB = B00000001; PORTD = B00000100;
delay(t);
PORTB = B00000000; PORTD = B10000100;
delay(t);
PORTB = B00000000; PORTD = B01000100;
delay(t);
PORTB = B00000000; PORTD = B00100100;
delay(t);
PORTB = B00000000; PORTD = B00010100;
delay(t);
PORTB = B00000000; PORTD = B00001100;
delay(t);
PORTB = B00001000; PORTD = B00001100;
delay(t);
PORTB = B00000100; PORTD = B00001100;
delay(t);
PORTB = B00000010; PORTD = B00001100;
delay(t);
PORTB = B00000001; PORTD = B00001100;
delay(t);
PORTB = B00000000; PORTD = B10001100;
delay(t);
PORTB = B00000000; PORTD = B01001100;
delay(t);
PORTB = B00000000; PORTD = B00101100;
delay(t);
PORTB = B00000000; PORTD = B00011100;
delay(t);
PORTB = B00001000; PORTD = B00011100;
delay(t);
PORTB = B00000100; PORTD = B00011100;
delay(t);
PORTB = B00000010; PORTD = B00011100;
delay(t);
PORTB = B00000001; PORTD = B00011100;
delay(t);
PORTB = B00000000; PORTD = B10011100;
delay(t);
PORTB = B00000000; PORTD = B01011100;
delay(t);
PORTB = B00000000; PORTD = B00111100;
delay(t);
PORTB = B00001000; PORTD = B00111100;
delay(t);
PORTB = B00000100; PORTD = B00111100;
delay(t);
PORTB = B00000010; PORTD = B00111100;
delay(t);
PORTB = B00000001; PORTD = B00111100;
delay(t);
PORTB = B00000000; PORTD = B10111100;
delay(t);
PORTB = B00000000; PORTD = B01111100;
delay(t);
PORTB = B00001000; PORTD = B01111100;
delay(t);
PORTB = B00000100; PORTD = B01111100;
delay(t);
PORTB = B00000010; PORTD = B01111100;
delay(t);
PORTB = B00000001; PORTD = B01111100;
delay(t);
PORTB = B00000000; PORTD = B11111100;
delay(t);
PORTB = B00000000; PORTD = B11111100;
delay(t);
PORTB = B00001000; PORTD = B11111100;
delay(t);
PORTB = B00000100; PORTD = B11111100;
delay(t);
PORTB = B00000010; PORTD = B11111100;
delay(t);
PORTB = B00000001; PORTD = B11111100;
delay(t);
PORTB = B00001001; PORTD = B11111100;
delay(t);
PORTB = B00000101; PORTD = B11111100;
delay(t);
PORTB = B00000011; PORTD = B11111100;
delay(t);
PORTB = B00001011; PORTD = B11111100;
delay(t);
PORTB = B00000111; PORTD = B11111100;
delay(t);
PORTB = B00001111; PORTD = B11111100;
delay(t);
}


void golst() {
  // golire spre stanga
PORTB = B00000111; PORTD = B11111100;
delay(t);
PORTB = B00001011; PORTD = B11111100;
delay(t);
PORTB = B00000011; PORTD = B11111100;
delay(t);
PORTB = B00000101; PORTD = B11111100;
delay(t);
PORTB = B00001001; PORTD = B11111100;
delay(t);
PORTB = B00000001; PORTD = B11111100;
delay(t);
PORTB = B00000010; PORTD = B11111100;
delay(t);
PORTB = B00000100; PORTD = B11111100;
delay(t);
PORTB = B00001000; PORTD = B11111100;
delay(t);
PORTB = B00000000; PORTD = B11111100;
delay(t);
PORTB = B00000001; PORTD = B01111100;
delay(t);
PORTB = B00000010; PORTD = B01111100;
delay(t);
PORTB = B00000100; PORTD = B01111100;
delay(t);
PORTB = B00001000; PORTD = B01111100;
delay(t);
PORTB = B00000000; PORTD = B01111100;
delay(t);
PORTB = B00000000; PORTD = B10111100;
delay(t);
PORTB = B00000001; PORTD = B00111100;
delay(t);
PORTB = B00000010; PORTD = B00111100;
delay(t);
PORTB = B00000100; PORTD = B00111100;
delay(t);
PORTB = B00001000; PORTD = B00111100;
delay(t);
PORTB = B00000000; PORTD = B00111100;
delay(t);
PORTB = B00000000; PORTD = B01011100;
delay(t);
PORTB = B00000000; PORTD = B10011100;
delay(t);
PORTB = B00000001; PORTD = B00011100;
delay(t);
PORTB = B00000010; PORTD = B00011100;
delay(t);
PORTB = B00000100; PORTD = B00011100;
delay(t);
PORTB = B00001000; PORTD = B00011100;
delay(t);
PORTB = B00000000; PORTD = B00101100;
delay(t);
PORTB = B00000000; PORTD = B01001100;
delay(t);
PORTB = B00000000; PORTD = B10001100;
delay(t);
PORTB = B00000001; PORTD = B00001100;
delay(t);
PORTB = B00000010; PORTD = B00001100;
delay(t);
PORTB = B00000100; PORTD = B00001100;
delay(t);
PORTB = B00001000; PORTD = B00001100;
delay(t);
PORTB = B00000000; PORTD = B00001100;
delay(t);
PORTB = B00000000; PORTD = B00010100;
delay(t);
PORTB = B00000000; PORTD = B00100100;
delay(t);
PORTB = B00000000; PORTD = B01000100;
delay(t);
PORTB = B00000000; PORTD = B10000100;
delay(t);
PORTB = B00000001; PORTD = B00000100;
delay(t);
PORTB = B00000010; PORTD = B00000100;
delay(t);
PORTB = B00000100; PORTD = B00000100;
delay(t);
PORTB = B00001000; PORTD = B00000100;
delay(t);
PORTB = B00000000; PORTD = B00000100;
delay(t);
PORTB = B00000000; PORTD = B00001000;
delay(t);
PORTB = B00000000; PORTD = B00010000;
delay(t);
PORTB = B00000000; PORTD = B00100000;
delay(t);
PORTB = B00000000; PORTD = B01000000;
delay(t);
PORTB = B00000000; PORTD = B10000000;
delay(t);
PORTB = B00000001; PORTD = B00000000;
delay(t);
PORTB = B00000010; PORTD = B00000000;
delay(t);
PORTB = B00000100; PORTD = B00000000;
delay(t);
PORTB = B00001000; PORTD = B00000000;
delay(t);
PORTB = B00000000; PORTD = B00000000;
delay(t);
}

void goldr() {
  // golire spre dreapta
PORTB = B00001111; PORTD = B11111000;
delay(t);
PORTB = B00001111; PORTD = B11110100;
delay(t);
PORTB = B00001111; PORTD = B11110000;
delay(t);
PORTB = B00001111; PORTD = B11101000;
delay(t);
PORTB = B00001111; PORTD = B11100100;
delay(t);
PORTB = B00001111; PORTD = B11100000;
delay(t);
PORTB = B00001111; PORTD = B11010000;
delay(t);
PORTB = B00001111; PORTD = B11001000;
delay(t);
PORTB = B00001111; PORTD = B11000100;
delay(t);
PORTB = B00001111; PORTD = B11000000;
delay(t);
PORTB = B00001111; PORTD = B10100000;
delay(t);
PORTB = B00001111; PORTD = B10010000;
delay(t);
PORTB = B00001111; PORTD = B10001000;
delay(t);
PORTB = B00001111; PORTD = B10000100;
delay(t);
PORTB = B00001111; PORTD = B10000000;
delay(t);
PORTB = B00001111; PORTD = B01000000;
delay(t);
PORTB = B00001111; PORTD = B00100000;
delay(t);
PORTB = B00001111; PORTD = B00010000;
delay(t);
PORTB = B00001111; PORTD = B00001000;
delay(t);
PORTB = B00001111; PORTD = B00000100;
delay(t);
PORTB = B00001111; PORTD = B00000000;
delay(t);
PORTB = B00001110; PORTD = B10000000;
delay(t);
PORTB = B00001110; PORTD = B01000000;
delay(t);
PORTB = B00001110; PORTD = B00100000;
delay(t);
PORTB = B00001110; PORTD = B00010000;
delay(t);
PORTB = B00001110; PORTD = B00001000;
delay(t);
PORTB = B00001110; PORTD = B00000100;
delay(t);
PORTB = B00001110; PORTD = B00000000;
delay(t);
PORTB = B00001101; PORTD = B00000000;
delay(t);
PORTB = B00001100; PORTD = B10000000;
delay(t);
PORTB = B00001100; PORTD = B01000000;
delay(t);
PORTB = B00001100; PORTD = B00100000;
delay(t);
PORTB = B00001100; PORTD = B00010000;
delay(t);
PORTB = B00001100; PORTD = B00001000;
delay(t);
PORTB = B00001100; PORTD = B00000100;
delay(t);
PORTB = B00001100; PORTD = B00000000;
delay(t);
PORTB = B00001010; PORTD = B00000000;
delay(t);
PORTB = B00001001; PORTD = B00000000;
delay(t);
PORTB = B00001000; PORTD = B10000000;
delay(t);
PORTB = B00001000; PORTD = B01000000;
delay(t);
PORTB = B00001000; PORTD = B00100000;
delay(t);
PORTB = B00001000; PORTD = B00010000;
delay(t);
PORTB = B00001000; PORTD = B00001000;
delay(t);
PORTB = B00001000; PORTD = B00000100;
delay(t);
PORTB = B00001000; PORTD = B00000000;
delay(t);
PORTB = B00000100; PORTD = B00000000;
delay(t);
PORTB = B00000010; PORTD = B00000000;
delay(t);
PORTB = B00000001; PORTD = B00000000;
delay(t);
PORTB = B00000000; PORTD = B10000000;
delay(t);
PORTB = B00000000; PORTD = B01000000;
delay(t);
PORTB = B00000000; PORTD = B00100000;
delay(t);
PORTB = B00000000; PORTD = B00010000;
delay(t);
PORTB = B00000000; PORTD = B00001000;
delay(t);
PORTB = B00000000; PORTD = B00000100;
delay(t);
}

void unledstdr() {  
PORTB = B00001000; PORTD = B00000000; // trimite valoarea binara direct la port B si apoi D
delay(t);
PORTB = B00000100; PORTD = B00000000;
delay(t);
PORTB = B00000010; PORTD = B00000000;
delay(t);
PORTB = B00000001; PORTD = B00000000;
delay(t);
PORTB = B00000000; PORTD = B10000000;
delay(t);
PORTB = B00000000; PORTD = B01000000;
delay(t);
PORTB = B00000000; PORTD = B00100000;
delay(t);
PORTB = B00000000; PORTD = B00010000;
delay(t);
PORTB = B00000000; PORTD = B00001000;
delay(t);
PORTB = B00000000; PORTD = B00000100;
delay(t);
}

void doiledstdr() {
// 2 leduri se deplaseaza de la stanga la dreapta
PORTB = B00001000; PORTD = B00000000;
delay(t);
PORTB = B00001100; PORTD = B00000000;
delay(t);
PORTB = B00000110; PORTD = B00000000;
delay(t);
PORTB = B00000011; PORTD = B00000000;
delay(t);
PORTB = B00000001; PORTD = B10000000;
delay(t);
PORTB = B00000000; PORTD = B11000000;
delay(t);
PORTB = B00000000; PORTD = B01100000;
delay(t);
PORTB = B00000000; PORTD = B00110000;
delay(t);
PORTB = B00000000; PORTD = B00011000;
delay(t);
PORTB = B00000000; PORTD = B00001100;
delay(t);
PORTB = B00000000; PORTD = B00000100;
delay(t);
}

void treiledstdr() {
// 3 leduri se deplaseaza de la stanga la dreapta
PORTB = B00001000; PORTD = B00000000;
delay(t);
PORTB = B00001100; PORTD = B00000000;
delay(t);
PORTB = B00001110; PORTD = B00000000;
delay(t);
PORTB = B00000111; PORTD = B00000000;
delay(t);
PORTB = B00000011; PORTD = B10000000;
delay(t);
PORTB = B00000001; PORTD = B11000000;
delay(t);
PORTB = B00000000; PORTD = B11100000;
delay(t);
PORTB = B00000000; PORTD = B0111000;
delay(t);
PORTB = B00000000; PORTD = B00111000;
delay(t);
PORTB = B00000000; PORTD = B00011100;
delay(t);
PORTB = B00000000; PORTD = B00001100;
delay(t);
PORTB = B00000000; PORTD = B00000100;
delay(t);
}

void patruledstdr() {
// 4 leduri se deplaseaza de la stanga la dreapta
PORTB = B00001000; PORTD = B00000000;
delay(t);
PORTB = B00001100; PORTD = B00000000;
delay(t);
PORTB = B00001110; PORTD = B00000000;
delay(t);
PORTB = B00001111; PORTD = B00000000;
delay(t);
PORTB = B00000111; PORTD = B10000000;
delay(t);
PORTB = B00000011; PORTD = B11000000;
delay(t);
PORTB = B00000001; PORTD = B11100000;
delay(t);
PORTB = B00000000; PORTD = B1111000;
delay(t);
PORTB = B00000000; PORTD = B01111000;
delay(t);
PORTB = B00000000; PORTD = B00111100;
delay(t);
PORTB = B00000000; PORTD = B00011100;
delay(t);
PORTB = B00000000; PORTD = B00001100;
delay(t);
PORTB = B00000000; PORTD = B00000100;
delay(t);
}

   Am facut un filmulet, numit joc lumini 10 canale (8), care prezinta jocul (combinatia) de lumini se executa conform sketch-ului prezentat anterior:
30.05.2015
   Am transferat montajul pe un cablaj independent, cu ajutorul lui Cristi din Satu Mare. Montajul este, acum in Irlanda, pus intr-un tablou electric cu relee statice, ce comanda benzi de LED-uri:
 

3 comentarii:

Senzor de masurare tensiune si curent INA219

   Am achizitionat de curand, de la colaboratorii mei de la  ArduShop.ro , un modul cu senzor INA219, care poate masura tensiuni pana la 26V...