arduino and demultiplexing

hi,
I’ve to use a demultiplexer to light some led diodes.
From arduino i give a decimal number (called “risultato”) and I want to light the diodes in the 0101 combination.
Following there’s my program, but it doesn’t work, can you give me some help? I’ ve got to test it tomorrow…

int risultato,i,num,num2=0,a,b,c;
#define S0 6
#define S1 5
#define S2 4
#define enable 7
void setup() {
pinMode(S0,OUTPUT);
pinMode(S1,OUTPUT);
pinMode(S2,OUTPUT);
pinMode(enable,OUTPUT);

}

void loop() {
risultato = 5;
for (i = 0; i <5; i++) {
num = num2;
a = num % 2;
num = num / 2;
b = num % 2;
num = num / 2;
c = num % 2;
digitalWrite(S0, a);
digitalWrite(S1, b);
digitalWrite(S2, c);
if(i=0)
{
if(risultato%2)
digitalWrite(enable, LOW);
else
digitalWrite(enable, HIGH);
}
if(i=1)
{
if((risultato==2)||(risultato==3)||(risultato==6)||(risultato==7)||(risultato==10)||(risultato==11)||(risultato==14)||(risultato==15))
digitalWrite(enable, LOW);
else
digitalWrite(enable, HIGH);
}
if(i=2)
{
if((risultato==4)||(risultato==5)||(risultato==6)||(risultato==7)||(risultato==12)||(risultato==13)||(risultato==14)||(risultato==15))
digitalWrite(enable, LOW);
else
digitalWrite(enable, HIGH);
}
if(i=3)
{
if(risultato>=8)
digitalWrite(enable, LOW);
else
digitalWrite(enable, HIGH);
}
if(i=4)
{
i=0;
if(risultato>15)
digitalWrite(enable, LOW);
}
num2++;

}
}

Please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum

Complex IF statements like

if((risultato==2)||(risultato==3)||(risultato==6)||(risultato==7)||(risultato==10)||(risultato==11)||(risultato==14)||(risultato==15))

are very easy to get wrong, especially if they are followed by an ELSE.

More importantly, you may be missing a { at the end of that statement.

…R

if(i=0)

It's unusual to see an assignment in an if statement.