Ciao ragazzi!
ho realizzato uno sketch che permette di controllare i colori di una matrice di 16 led RGB ( 4x 4) (con le masse controllate da 4 bjt)
funziona, per configurare i led, bisogna regolare i valori binari dei 3 array 2D (matrici), uno per ogni colore!
Il mio lavoro ora, consiste nel fare in modo che quei valori negli array vengano cambiati in tempo reale tramite seriale, quindi per poterli
int ledGND[] = {10,11,12,13};
int red[] = {17,16,15,14};
int green[] = {2,3,4,5};
int blue[] = {6,7,8,9};
int n = 0;
int n2 = 0;byte REDvalue[4][4] = {
{HIGH,LOW,LOW,HIGH},
{LOW,HIGH,HIGH,LOW},
{LOW,HIGH,HIGH,LOW},
{HIGH,LOW,LOW,HIGH}
};byte GREENvalue[4][4] = {
{LOW,HIGH,HIGH,LOW},
{LOW,LOW,LOW,LOW},
{LOW,LOW,LOW,LOW},
{LOW,HIGH,HIGH,LOW}
};
byte BLUEvalue[4][4] = {
{LOW,LOW,LOW,LOW},
{HIGH,LOW,LOW,HIGH},
{HIGH,LOW,LOW,HIGH},
{LOW,LOW,LOW,LOW}
};// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
for (int thisPin = 0; thisPin < 4; thisPin++) {
pinMode(ledGND[thisPin], OUTPUT);
}
for (int thisPin = 0; thisPin < 4; thisPin++) {
pinMode(red[thisPin], OUTPUT);
}
for (int thisPin = 0; thisPin < 4; thisPin++) {
pinMode(green[thisPin], OUTPUT);
}
for (int thisPin = 0; thisPin < 4; thisPin++) {
pinMode(blue[thisPin], OUTPUT);
}
Serial.begin(9600);
}// the loop routine runs over and over again forever:
void loop() {
for(n2=0; n2<4; n2++){
digitalWrite(ledGND[n2], HIGH);
for(n=0; n<4; n++) {
digitalWrite(red[n],REDvalue[n2][n]);
digitalWrite(green[n], GREENvalue[n2][n]);
digitalWrite(blue[n], BLUEvalue[n2][n]);
//delay(500);
//digitalWrite(green[n], LOW);
}
// turn the LED off by making the vol // wait for a second
delayMicroseconds(500);
digitalWrite(ledGND[n2], LOW);digitalWrite(red[0], LOW);
digitalWrite(red[1], LOW);
digitalWrite(red[2], LOW);
digitalWrite(red[3], LOW);digitalWrite(green[0], LOW);
digitalWrite(green[1], LOW);
digitalWrite(green[2], LOW);
digitalWrite(green[3], LOW);digitalWrite(blue[0], LOW);
digitalWrite(blue[1], LOW);
digitalWrite(blue[2], LOW);
digitalWrite(blue[3], LOW);
}
}
Grazie