Dubbio,Difetto Hardware o Software

Ciao,dal consiglio di questo link : http://forum.arduino.cc/index.php?topic=492121.0;topicseen
ho acquistato i driver della serie mic2981 avendo a disposizione dei led rgb ho creato nel tempo 2 display 7 segmenti.
Assemblato il circuito ho creato un codice [ Allego Codice Anomalo ] per verificare l’accensione almeno nel colore verde dei led rgb.
Questo codice mi ha creato dei problemi ( onestamente non riesco a capire dove sbaglio ) perchè alcuni segmenti mi rimangono accesi a " mezza luce " quando dovrebbero essere spenti.
Non riuscendo a capire se il problema fosse hw o del codice [ Allego Codice NO Anomalia ,ho scritto un altro codice,non proprio uguale,ma penso che mi faccia escludere un " bugs " Hardware,almeno penso.

Allego [ Codice Anomalo ] :

extern unsigned long timer0_millis; //

int digit1 = A2;     				// Display pin xx [ Decine    ]
int digit2 = A1;					// Display pin xx [ Unità     ]

int segA = 2;       				// 
int segB = 3;       				// 
int segC = 4;       				// 
int segD = 5;       				// 
int segE = 6;       				//  
int segF = 7;  	    				// 
int segG = 8; 	     				// 
int start_num_valore = 99;	  	        // 
int seg_ON = 0;						//
int valore;							//
int pwm_v = 9;						//
int pwm_v_on = 255;
int pwm_v_off =  0;

void setup() {     

	pinMode(segA, OUTPUT);
	pinMode(segB, OUTPUT);
	pinMode(segC, OUTPUT);
	pinMode(segD, OUTPUT);
	pinMode(segE, OUTPUT);
	pinMode(segF, OUTPUT);
	pinMode(segG, OUTPUT);
	pinMode(digit1, OUTPUT);
	pinMode(digit2, OUTPUT);	
	pinMode(pwm_v, OUTPUT);
	timer0_millis = 0 ;

}

void loop () {

	if (seg_ON==0) {
		if (((millis()/1000) <= start_num_valore)) {
			displayNumber (start_num_valore -(millis()/1000));
			valore = (start_num_valore -(millis()/1000));
		}
		else
		{
			timer0_millis = 0 ;
		}
	}   
}  

void displayNumber(int toDisplay) {
	#define DISPLAY_LUMINOSITA  5000  // Vmax luminosità 5000

	#define DIGIT_ON  HIGH
	#define DIGIT_OFF  LOW

	long beginTime = millis();

	for(int digit = 2 ; digit > 0 ; digit--) {

//
// Rotazione dei  Digit 1+2 [ D+U ] in funzione On / Off
//

switch(digit) {

	case 1:
	if(valore >= 10) {
		digitalWrite(digit1, DIGIT_ON);
		break;
	}
	else
	{
		digitalWrite(digit1, DIGIT_OFF);
		break;
	}

	case 2:
	digitalWrite(digit2, DIGIT_ON);
	break;

}

//
// Gestione Display con il Pwm
//

lightNumber(toDisplay % 10);
toDisplay /= 10;

       //Display digit luminosità (...da 1us a 5000us, 500 Valore di Default...)
       delayMicroseconds(DISPLAY_LUMINOSITA); 

		//Spegni tutti i Segmenti
		lightNumber(10); 

		//Spegni tutti i digit
		digitalWrite(digit1, DIGIT_OFF);
		digitalWrite(digit2, DIGIT_OFF);
		analogWrite(pwm_v, pwm_v_off);
	}
	while((millis() - beginTime) < 10) ; 
}

void lightNumber(int numberToDisplay) {

	#define SEGMENT_ON  HIGH
	#define SEGMENT_OFF LOW

	switch (numberToDisplay) {

		case 0:
		if(valore >= 1) {
			digitalWrite(segA, SEGMENT_ON);
			digitalWrite(segB, SEGMENT_ON);
			digitalWrite(segC, SEGMENT_ON);
			digitalWrite(segD, SEGMENT_ON);
			digitalWrite(segE, SEGMENT_ON);
			digitalWrite(segF, SEGMENT_ON);
			digitalWrite(segG, SEGMENT_OFF);
			analogWrite(pwm_v, pwm_v_on);

			break;
		}
		else {
			digitalWrite(segA, SEGMENT_OFF);
			digitalWrite(segB, SEGMENT_OFF);
			digitalWrite(segC, SEGMENT_OFF);
			digitalWrite(segD, SEGMENT_OFF);
			digitalWrite(segE, SEGMENT_OFF);
			digitalWrite(segF, SEGMENT_OFF);
			digitalWrite(segG, SEGMENT_OFF);
			analogWrite(pwm_v, pwm_v_off);
			break;
		}

		case 1:
		digitalWrite(segA, SEGMENT_OFF);
		digitalWrite(segB, SEGMENT_ON);
		digitalWrite(segC, SEGMENT_ON);
		digitalWrite(segD, SEGMENT_OFF);
		digitalWrite(segE, SEGMENT_OFF);
		digitalWrite(segF, SEGMENT_OFF);
		digitalWrite(segG, SEGMENT_OFF);
		analogWrite(pwm_v, pwm_v_on);
		break;

		case 2:
		digitalWrite(segA, SEGMENT_ON);
		digitalWrite(segB, SEGMENT_ON);
		digitalWrite(segC, SEGMENT_OFF);
		digitalWrite(segD, SEGMENT_ON);
		digitalWrite(segE, SEGMENT_ON);
		digitalWrite(segF, SEGMENT_OFF);
		digitalWrite(segG, SEGMENT_ON);
		analogWrite(pwm_v, pwm_v_on);

		break;

		case 3:
		digitalWrite(segA, SEGMENT_ON);
		digitalWrite(segB, SEGMENT_ON);
		digitalWrite(segC, SEGMENT_ON);
		digitalWrite(segD, SEGMENT_ON);
		digitalWrite(segE, SEGMENT_OFF);
		digitalWrite(segF, SEGMENT_OFF);
		digitalWrite(segG, SEGMENT_ON);
		analogWrite(pwm_v, pwm_v_on);
		break;

		case 4:
		digitalWrite(segA, SEGMENT_OFF);
		digitalWrite(segB, SEGMENT_ON);
		digitalWrite(segC, SEGMENT_ON);
		digitalWrite(segD, SEGMENT_OFF);
		digitalWrite(segE, SEGMENT_OFF);
		digitalWrite(segF, SEGMENT_ON);
		digitalWrite(segG, SEGMENT_ON);
		analogWrite(pwm_v, pwm_v_on);
		break;

		case 5:
		digitalWrite(segA, SEGMENT_ON);
		digitalWrite(segB, SEGMENT_OFF);
		digitalWrite(segC, SEGMENT_ON);
		digitalWrite(segD, SEGMENT_ON);
		digitalWrite(segE, SEGMENT_OFF);
		digitalWrite(segF, SEGMENT_ON);
		digitalWrite(segG, SEGMENT_ON);
		analogWrite(pwm_v, pwm_v_on);
		break;

		case 6:
		digitalWrite(segA, SEGMENT_ON);
		digitalWrite(segB, SEGMENT_OFF);
		digitalWrite(segC, SEGMENT_ON);
		digitalWrite(segD, SEGMENT_ON);
		digitalWrite(segE, SEGMENT_ON);
		digitalWrite(segF, SEGMENT_ON);
		digitalWrite(segG, SEGMENT_ON);
		analogWrite(pwm_v, pwm_v_on);
		break;

		case 7:
		digitalWrite(segA, SEGMENT_ON);
		digitalWrite(segB, SEGMENT_ON);
		digitalWrite(segC, SEGMENT_ON);
		digitalWrite(segD, SEGMENT_OFF);
		digitalWrite(segE, SEGMENT_OFF);
		digitalWrite(segF, SEGMENT_OFF);
		digitalWrite(segG, SEGMENT_OFF);
		analogWrite(pwm_v, pwm_v_on);
		break;

		case 8:
		digitalWrite(segA, SEGMENT_ON);
		digitalWrite(segB, SEGMENT_ON);
		digitalWrite(segC, SEGMENT_ON);
		digitalWrite(segD, SEGMENT_ON);
		digitalWrite(segE, SEGMENT_ON);
		digitalWrite(segF, SEGMENT_ON);
		digitalWrite(segG, SEGMENT_ON);
		analogWrite(pwm_v, pwm_v_on);
		break;

		case 9:
		digitalWrite(segA, SEGMENT_ON);
		digitalWrite(segB, SEGMENT_ON);
		digitalWrite(segC, SEGMENT_ON);
		digitalWrite(segD, SEGMENT_ON);
		digitalWrite(segE, SEGMENT_OFF);
		digitalWrite(segF, SEGMENT_ON);
		digitalWrite(segG, SEGMENT_ON);
		analogWrite(pwm_v, pwm_v_on);
		break;

		case 10:
		digitalWrite(segA, SEGMENT_OFF);
		digitalWrite(segB, SEGMENT_OFF);
		digitalWrite(segC, SEGMENT_OFF);
		digitalWrite(segD, SEGMENT_OFF);
		digitalWrite(segE, SEGMENT_OFF);
		digitalWrite(segF, SEGMENT_OFF);
		digitalWrite(segG, SEGMENT_OFF);
		digitalWrite(digit1, DIGIT_OFF);
		digitalWrite(digit2, DIGIT_OFF);
		analogWrite(pwm_v, pwm_v_off);
		break;
	}
}

Se qualcuno mi riesce a dare a qualche dritta,lo ringrazio in anticipo.
I led comunque essendo del tipo 5mm non ho potuto pilotarli in serie ,ma ad ogni led una sua resistenza in serie ( Catodo Comune ) e pilotato dall’uscita del driver MICxxxxx.
Tensione di pilotaggio 12Vcc.
Il Codice [ No Anomalia ] lo allego successivamente perchè ,il portale mi dice che ho superato i 9000 caratteri.

Grazie,Mauro
[/code]

Allego Codice [ NO Anomalia ] :

#define SEGMENT_ON  HIGH
#define SEGMENT_OFF LOW

extern unsigned long timer0_millis; //

int digit1 = A2;     				// Display [ Decine    ]
int digit2 = A1;					// Display [ Unità     ]
int segA = 2;       				// 
int segB = 3;       				// 
int segC = 4;       				// 
int segD = 5;       				// 
int segE = 6;       				// 
int segF = 7;  	    				// 
int segG = 8; 	     				// 
int seg_ON = 0;						//
int Time_On = 1000;					// Clock 1"
int seg_ON_VGR = 0;
int start = 0;
int pwm_v = 9;						// Enable pin Green Led RGB
int pwm_r = 10;						// Enable pin Red   Led RGB
int pwm_v_on = 255;					// Green Valore Analogico 255
int pwm_v_off =  0;
int pwm_vg_on = 44;					// Green Tarato per Yellow Valore Analogico 44				    
int pwm_rg_on = 255;				// Red   Tarato per Yellow Valore Analogico 255
int pwm_r_on = 255;					// Red Valore Analogico 255
int pwm_r_off =  0;

void setup() {     

	pinMode(segA, OUTPUT);
	pinMode(segB, OUTPUT);
	pinMode(segC, OUTPUT);
	pinMode(segD, OUTPUT);
	pinMode(segE, OUTPUT);
	pinMode(segF, OUTPUT);
	pinMode(segG, OUTPUT);
	pinMode(digit1, OUTPUT);
	pinMode(digit2, OUTPUT);	
	pinMode(pwm_v, OUTPUT);
	pinMode(pwm_r, OUTPUT);

}

void loop() {

	Sequenza_Write_VGR();
	Sequenza_VGR();
}

void Sequenza_Write_VGR () {

	if (seg_ON_VGR ==0) {
		digitalWrite(digit1, HIGH);
		digitalWrite(digit2, HIGH);
		analogWrite(pwm_v, pwm_v_on);
		analogWrite(pwm_r, pwm_r_off);
	}

	if (seg_ON_VGR ==1) {
		digitalWrite(digit1, HIGH);
		digitalWrite(digit2, HIGH);
		analogWrite(pwm_v, pwm_vg_on);
		analogWrite(pwm_r, pwm_rg_on);
	}

	if (seg_ON_VGR ==2) {
		digitalWrite(digit1, HIGH);
		digitalWrite(digit2, HIGH);
		analogWrite(pwm_v, pwm_v_off);
		analogWrite(pwm_r, pwm_r_on);
	}
}

void Sequenza_VGR () {

//
// Test [0] 
//

if (seg_ON==0) {
		digitalWrite(segA, SEGMENT_ON);
		digitalWrite(segB, SEGMENT_ON);
		digitalWrite(segC, SEGMENT_ON);
		digitalWrite(segD, SEGMENT_ON);
		digitalWrite(segE, SEGMENT_OFF);
		digitalWrite(segF, SEGMENT_ON);
		digitalWrite(segG, SEGMENT_ON);
	delay(Time_On);
	seg_ON=1;
	start=1;
	timer0_millis = 0 ;
}

//
// Test [1] 
//

if (seg_ON==1) {
	digitalWrite(segA, SEGMENT_ON);
		digitalWrite(segB, SEGMENT_ON);
		digitalWrite(segC, SEGMENT_ON);
		digitalWrite(segD, SEGMENT_ON);
		digitalWrite(segE, SEGMENT_ON);
		digitalWrite(segF, SEGMENT_ON);
		digitalWrite(segG, SEGMENT_ON);
	delay(Time_On);
	seg_ON=2;
	timer0_millis = 0 ;
}

//
// Test [2]
//

if (seg_ON==2) {
		digitalWrite(segA, SEGMENT_ON);
		digitalWrite(segB, SEGMENT_ON);
		digitalWrite(segC, SEGMENT_ON);
		digitalWrite(segD, SEGMENT_OFF);
		digitalWrite(segE, SEGMENT_OFF);
		digitalWrite(segF, SEGMENT_OFF);
		digitalWrite(segG, SEGMENT_OFF);
	delay(Time_On);
	seg_ON=3;
	timer0_millis = 0 ;
}

//
// Test [3] 
//

if (seg_ON==3) {
		digitalWrite(segA, SEGMENT_ON);
		digitalWrite(segB, SEGMENT_OFF);
		digitalWrite(segC, SEGMENT_ON);
		digitalWrite(segD, SEGMENT_ON);
		digitalWrite(segE, SEGMENT_ON);
		digitalWrite(segF, SEGMENT_ON);
		digitalWrite(segG, SEGMENT_ON);
	delay(Time_On);
	seg_ON=4;
	timer0_millis = 0 ;
}

//
// Test [4] 
//

if (seg_ON==4) {
		digitalWrite(segA, SEGMENT_ON);
		digitalWrite(segB, SEGMENT_OFF);
		digitalWrite(segC, SEGMENT_ON);
		digitalWrite(segD, SEGMENT_ON);
		digitalWrite(segE, SEGMENT_OFF);
		digitalWrite(segF, SEGMENT_ON);
		digitalWrite(segG, SEGMENT_ON);
	delay(Time_On);
	seg_ON=5;
	timer0_millis = 0 ;
}

//
// Test [5]
//

if (seg_ON==5) {
		digitalWrite(segA, SEGMENT_OFF);
		digitalWrite(segB, SEGMENT_ON);
		digitalWrite(segC, SEGMENT_ON);
		digitalWrite(segD, SEGMENT_OFF);
		digitalWrite(segE, SEGMENT_OFF);
		digitalWrite(segF, SEGMENT_ON);
		digitalWrite(segG, SEGMENT_ON);
	delay(Time_On);
	seg_ON=6;
	timer0_millis = 0 ;
}

//
// Test [6] 
//

if (seg_ON==6) {
		digitalWrite(segA, SEGMENT_ON);
		digitalWrite(segB, SEGMENT_ON);
		digitalWrite(segC, SEGMENT_ON);
		digitalWrite(segD, SEGMENT_ON);
		digitalWrite(segE, SEGMENT_OFF);
		digitalWrite(segF, SEGMENT_OFF);
		digitalWrite(segG, SEGMENT_ON);
	delay(Time_On);
	seg_ON=7;
	timer0_millis = 0 ;
}

//
// Test [7] 
//

if (seg_ON==7) {
		digitalWrite(segA, SEGMENT_ON);
		digitalWrite(segB, SEGMENT_ON);
		digitalWrite(segC, SEGMENT_OFF);
		digitalWrite(segD, SEGMENT_ON);
		digitalWrite(segE, SEGMENT_ON);
		digitalWrite(segF, SEGMENT_OFF);
		digitalWrite(segG, SEGMENT_ON);
	delay(Time_On);
	seg_ON=8;
	timer0_millis = 0 ;
}

//
// Test [8] 
//

if (seg_ON==8) {
		digitalWrite(segA, SEGMENT_OFF);
		digitalWrite(segB, SEGMENT_ON);
		digitalWrite(segC, SEGMENT_ON);
		digitalWrite(segD, SEGMENT_OFF);
		digitalWrite(segE, SEGMENT_OFF);
		digitalWrite(segF, SEGMENT_OFF);
		digitalWrite(segG, SEGMENT_OFF);
	delay(Time_On);
	seg_ON=9;
	timer0_millis = 0 ;
}

//
// Test [9] 
//

if (seg_ON==9) {
		digitalWrite(segA, SEGMENT_ON);
		digitalWrite(segB, SEGMENT_ON);
		digitalWrite(segC, SEGMENT_ON);
		digitalWrite(segD, SEGMENT_ON);
		digitalWrite(segE, SEGMENT_ON);
		digitalWrite(segF, SEGMENT_ON);
		digitalWrite(segG, SEGMENT_OFF);
	delay(Time_On);
	seg_ON=0;
	timer0_millis = 0 ;
}

if ((seg_ON_VGR ==0) && (start ==1)) {
	seg_ON_VGR = 1;
	start = 0;
}

if ((seg_ON_VGR ==1) && (start ==1)) {
	seg_ON_VGR = 2;
	start = 0;
}

if ((seg_ON_VGR ==2) && (start ==1)) {
	seg_ON_VGR = 0;
	start = 0;
}

}

Ma come é il circuito?

Ciao,il circuito in questo momento non l'ho postato perchè lo " disegnato / Bozzato " su foglio di brutta ,potrei metterlo in bella,ma vedendo che il secondo codice " NO Anomalia " mi funziona correttamente,pensavo che non fosse così fondamentale vederlo.
Magari adesso mi metto d'impegno per fare uno schema per Veriifca per gli utenti.
Grazie

Ciao,allego lo schema sperando che si riesca a capire.
Grazie

Schema_7SEG_2D.pdf (576 KB)

Ciao,onestamente verificando i due codici e il circuito ,mi sembra strano che un codice mi funzioni correttamente rispetto all'altro ,quindi penso il circuito lo debba escludere e ricercare il il difetto sul codice.
Facendo un pò di prove,ho verificato che gli errori " accensione a mezza luce di un segmento che dovrebbe essere spento " sono costanti.

Segmenti accesi a Mezza luce per Numero :

Decine 9 corretto / Unità 1..9 corretti
Decine 8 corretto / Unità 1..9 corretti
Decine 7 corretto / Unità 1..9 corretti
Decine 6 segmento B / Unità 1..9 corretti
Decine 5 segmento B / Unità 1..9 corretti
Decine 4 corretto / Unità 1..9 corretti
Decine 3 corretto / Unità 1..9 corretti
Decine 2 segmento C / Unità 9 segmento E
" 2 segmento C / Unità 8 corretto
" 2 segmento C / Unità 7 segmento D,E,G
" 2 segmento C / Unità 6 segmento G
" 2 segmento C / Unità 5 segmento B,E
" 2 segmento C / Unità 4 segmento D,E
" 2 segmento C / Unità 3 segmento E
" 2 segmento C / Unità 2 corretto
" 2 segmento C / Unità 1 segmento A,D,E,G
" 2 segmento C / Unità 0 segmento G
Decine 1 corretto / Unità 1..9 corretti
Decine 0 sempre Spento corretto / Unità 1..9 corretti

Magari non vuol dire niente,ma forse potrebbe essere un indizio.Intanto vado avanti con le mie prove aspettando magari una dritta dai + esperti.
Grazie