Show Posts
Pages: [1] 2 3 ... 6
1  Using Arduino / Programming Questions / Re: help with : shiftregister + fading on: June 18, 2011, 04:46:54 pm
Now it is working and thanks alot again Mike .. that was a great help !

this my finished project :

http://www.youtube.com/embed/_alfuhazGJE
2  Using Arduino / Programming Questions / Re: help with : shiftregister + fading on: June 16, 2011, 05:34:58 pm
well i have 115 led's in parallel ( it is the same project, i just tried to simplify my drawing ) so i need an external power supply.

my wiring, is exactly like this ... it is  correct wired ?

3  Using Arduino / Programming Questions / Re: help with : shiftregister + fading on: June 16, 2011, 04:58:22 pm
that is exatly what i have :



on the right : led is working normaly !
on the left  : led is on but very very weak !

i just checked my wirings, and thery are exactly how discribed. there is no doubt that the wiring is wrong, i just cant figure out how
4  Using Arduino / Programming Questions / Re: help with : shiftregister + fading on: June 16, 2011, 04:40:35 pm
i just checked it .. it is a PNP transistor. The LEd is very very dim, BUT fading.
when i connect the GND from arduino to the PNP emetor ( which is also connected to the +5v of the extrenal power ) the Led lights normaly !

does it make any sens ?
5  Using Arduino / Programming Questions / Re: help with : shiftregister + fading on: June 16, 2011, 03:43:39 pm
sure I understand, thank you.

but a very very last question - and a quite banal one, But please what is wrong with that diagram ( i just cant get med led to lighten when i attach the external power ). i checked everything.

6  Using Arduino / Programming Questions / Re: help with : shiftregister + fading on: June 14, 2011, 05:37:15 pm
Quote
means only three LEDs on at the same time, from the same bank number, but you can individually control the brightness.

Exactly Mike .. thats what i understood .. the fact is i dont want to lighten 3 LEDs at the same time, but only one at a time, but does the wiring and code reflect that ? smiley
7  Using Arduino / Programming Questions / Re: help with : shiftregister + fading on: June 13, 2011, 09:50:22 am
Quote
then parallel the address lines but drive each enable line separately.

it is what i tried to do, paralleling the address lines ( A0-A1-A2 ) and enables lines ( E ) are drived separatly.



and the code will be :

Code:
  int OUTPUT1 = 2;
  int OUTPUT2 = 3;
  int OUTPUT3 = 4;
 
  int E1 = 5; //PWM1
  int E2 = 6; //PWM2
  int E3 = 7; //PWM3

  void setup()
  {
    pinMode(OUTPUT1, OUTPUT);
    pinMode(OUTPUT2, OUTPUT);
    pinMode(OUTPUT3, OUTPUT);
    pinMode(E3, OUTPUT);
  }
 
void selectLED(int num) { // select an LED to control
     if((num & 1) !=0) digitalWrite(OUTPUT1, HIGH); else digitalWrite(OUTPUT1, LOW);
     if((num & 2) !=0) digitalWrite(OUTPUT2, HIGH); else digitalWrite(OUTPUT2, LOW);
     if((num & 4) !=0) digitalWrite(OUTPUT3, HIGH); else digitalWrite(OUTPUT3, LOW);
}

void doFade(int Pwm_num){
 
  switch(Pwm_num)
    {
       case 1:
      for(byte fadeValue = 0 ; fadeValue <= 255; fadeValue +=5)
      {
        analogWrite(E1, fadeValue);         
        delay(30);                           
      }
   
      for(byte fadeValue = 255 ; fadeValue >= 0; fadeValue -=5)
      {
        analogWrite(E1, fadeValue);           
        delay(30);                           
      }
      break;
     
      case 2:
      for(byte fadeValue = 0 ; fadeValue <= 255; fadeValue +=5)
      {
        analogWrite(E2, fadeValue);         
        delay(30);                           
      }
   
      for(byte fadeValue = 255 ; fadeValue >= 0; fadeValue -=5)
      {
        analogWrite(E2, fadeValue);           
        delay(30);                           
      }
      break;
     
      case 3:
      for(byte fadeValue = 0 ; fadeValue <= 255; fadeValue +=5)
      {
        analogWrite(E3, fadeValue);         
        delay(30);                           
      }
   
      for(byte fadeValue = 255 ; fadeValue >= 0; fadeValue -=5)
      {
        analogWrite(E3, fadeValue);           
        delay(30);                           
      }
      break;
    }
}
 
 
void loop()
{
  int ran = random(0,21);
 
  if (ran < 8) { 
    selectLED(ran);
    doFade(1);
  }
    if (7 < ran < 17 ) { 
    selectLED(ran - 8);
    doFade(2);
  }
    if ( 16 < ran < 22) { 
    selectLED(ran - 17);
    doFade(3);
  }
}

as you can see, what i am trying to do is to enable the chip accroding to "ran" number ... but as i understood from your earlier replay that it is not the way to do it ... how then ?
8  Using Arduino / Programming Questions / Re: help with : shiftregister + fading on: June 13, 2011, 03:09:16 am
Quote
I thought you said you wanted all three LEDs to be on at the same time, you were going to parallel up all the signals.

no not really, that's why i was thinking f uing 3 74ls04 connected together, where only one of these is "on" at a time depanding on the value f the generated random number. but as understood from your post is that i'll still have 3 led's on if they are wired in parallel.

an idea could be to not connect the 7404 together at all, but in this case i will use 9 pins from arduino ( A0,A1,A3 - A4,A5,A6- A7,A8,A9 ] and 3 PWM other pins (E1 - E2 - E3 ) and activate one of ships according to the value of generated random number ... but is there a smarter way to connect the
 shis together so i dont use 13 pins of my arduino ?
9  Using Arduino / Programming Questions / Re: help with : shiftregister + fading on: June 12, 2011, 05:12:41 pm
Quote
Turn the LEDs round and connectbthe spair end to ground.

- i have to do that, to allow one led turning on at a time ? ( i dont want 3 led on at the same time ).
- what you mean is just switching the polarity of the led's right ?

and thanks a lot again. big help
10  Using Arduino / Programming Questions / Re: help with : shiftregister + fading on: June 12, 2011, 07:34:59 am
Quote
One output of the 138 feeds into the input of three inverters. The output of each inverter drives an LED / resistor in the current sourcing mode.



is it the way to wire it ? ( i only drawed 2 74ls04)

what about the code, i stille use the same code, because i cant figure it out, how one output from 138, will drive different leds connected to 3 7404.
11  Using Arduino / Programming Questions / Re: help with : shiftregister + fading on: June 11, 2011, 12:42:00 pm
Quote
only three LEDs on at the same time, from the same bank number, but you can individually control the brightness

yeah okay, i see .. that's what i got in the testing too .. but it is not what i am interessted in.

Quote
rubbish to use this chip for this purpose and no one in there right  mind would

let's say a newbe mistake smiley

allright then, how can i make this work with one ship and the 7404's ? i can't really figure it out even when looking at the datasheet of the 7404

12  Using Arduino / Programming Questions / Re: help with : shiftregister + fading on: June 11, 2011, 12:11:50 pm
Quote
I can't see the point in having three chips if all three chips are connected together. You might as well just have an output from one chip driving three buffers (74LS04 or similar).

i've been looking at the internet to see if i could finde somethuing┬┤that can help me to understand, but i could finde nothing really, so i really dont know how to do it.

but i was thinking about something like this :



and the code will be :

Code:
 int OUTPUT1 = 2;
  int OUTPUT2 = 3;
  int OUTPUT3 = 4;
  
  int E1 = 5; //PWM1
  int E2 = 6; //PWM2
  int E3 = 7; //PWM3

  void setup()
  {
    pinMode(OUTPUT1, OUTPUT);
    pinMode(OUTPUT2, OUTPUT);
    pinMode(OUTPUT3, OUTPUT);
    pinMode(E3, OUTPUT);
  }
  
void selectLED(int num) { // select an LED to control
     if((num & 1) !=0) digitalWrite(OUTPUT1, HIGH); else digitalWrite(OUTPUT1, LOW);
     if((num & 2) !=0) digitalWrite(OUTPUT2, HIGH); else digitalWrite(OUTPUT2, LOW);
     if((num & 4) !=0) digitalWrite(OUTPUT3, HIGH); else digitalWrite(OUTPUT3, LOW);
}

void doFade(int Pwm_num){
  
  switch(Pwm_num)
    {
       case 1:
      for(byte fadeValue = 0 ; fadeValue <= 255; fadeValue +=5)
      {
        analogWrite(E1, fadeValue);        
        delay(30);                            
      }
    
      for(byte fadeValue = 255 ; fadeValue >= 0; fadeValue -=5)
      {
        analogWrite(E1, fadeValue);          
        delay(30);                            
      }
      break;
      
      case 2:
      for(byte fadeValue = 0 ; fadeValue <= 255; fadeValue +=5)
      {
        analogWrite(E2, fadeValue);        
        delay(30);                            
      }
    
      for(byte fadeValue = 255 ; fadeValue >= 0; fadeValue -=5)
      {
        analogWrite(E2, fadeValue);          
        delay(30);                            
      }
      break;
      
      case 3:
      for(byte fadeValue = 0 ; fadeValue <= 255; fadeValue +=5)
      {
        analogWrite(E3, fadeValue);        
        delay(30);                            
      }
    
      for(byte fadeValue = 255 ; fadeValue >= 0; fadeValue -=5)
      {
        analogWrite(E3, fadeValue);          
        delay(30);                            
      }
      break;
    }
}
  
 
void loop()
{
  int ran = random(0,21);
  
  if (ran < 8) {  
    selectLED(ran);
    doFade(1);
  }
    if (7 < ran < 17 ) {  
    selectLED(ran - 8);
    doFade(2);
  }
    if ( 16 < ran < 22) {  
    selectLED(ran - 17);
    doFade(3);
  }
}

does it sounds faisable ?
13  Using Arduino / Programming Questions / Re: help with : shiftregister + fading on: June 11, 2011, 08:32:21 am
That worked like a charm ! .. a huge help, thanks alot Mike.

any idea why it didnt work with the other code ( even when i removed that function declaration in the begining ), just curious ?

and last question ... i planning to connect 3 demultiplexers in paralells, since i have 22 arrays of leds ( one array for every output ). the only thing i have to change is :

changnig : ran = random ( 0,7) to ran = random ( 0, 21 ) .. and leave every thing at it is, since A0-A2 and E3 for all the 3 ships will be conncted together. is it correct understood ?
14  Using Arduino / Programming Questions / Re: help with : shiftregister + fading on: June 11, 2011, 06:59:26 am
Code:
int OUTPUT1 = 2;
  int OUTPUT2 = 3;
  int OUTPUT3 = 4;
  int E3 = 5;
  int d = 0; // for delay


  void turnOn(int outputPin);

 
  void setup()
  {
    pinMode(OUTPUT1, OUTPUT);
    pinMode(OUTPUT2, OUTPUT);
    pinMode(OUTPUT3, OUTPUT);
    pinMode(E3, OUTPUT);
  }
 
  void turnOn(int outputPin)
  // turns on output at pin 'outputPin'
  {

      digitalWrite(E3, LOW);


      digitalWrite(OUTPUT1, LOW);
      digitalWrite(OUTPUT2, LOW);
      digitalWrite(OUTPUT3, LOW);


    switch(outputPin)
    {
     
      case 0:
      for(byte fadeValue = 0 ; fadeValue <= 255; fadeValue +=5)
      {
        analogWrite(E3, fadeValue);         
        delay(30);                           
      }
     
      case 1:
      digitalWrite(OUTPUT1, HIGH);
      for(byte fadeValue = 0 ; fadeValue <= 255; fadeValue +=5)
      {
        analogWrite(E3, fadeValue);         
        delay(30);                           
      }
   
      for(byte fadeValue = 255 ; fadeValue >= 0; fadeValue -=5)
      {
        analogWrite(E3, fadeValue);           
        delay(30);                           
      }
      break;
     
      case 2:
      digitalWrite(OUTPUT2, HIGH);
      for(byte fadeValue = 0 ; fadeValue <= 255; fadeValue +=5)
      {
        analogWrite(E3, fadeValue);         
        delay(30);                           
      }
   
      for(byte fadeValue = 255 ; fadeValue >= 0; fadeValue -=5)
      {
        analogWrite(E3, fadeValue);           
        delay(30);                           
      }
      break;
     
      case 3:
      digitalWrite(OUTPUT1, HIGH);
      digitalWrite(OUTPUT2, HIGH);
      for(byte fadeValue = 0 ; fadeValue <= 255; fadeValue +=5)
      {
        analogWrite(E3, fadeValue);         
        delay(30);                           
      }
   
      for(byte fadeValue = 255 ; fadeValue >= 0; fadeValue -=5)
      {
        analogWrite(E3, fadeValue);           
        delay(30);                           
      }
      break;
     
      case 4:
      digitalWrite(OUTPUT3, HIGH);
      for(byte fadeValue = 0 ; fadeValue <= 255; fadeValue +=5)
      {
        analogWrite(E3, fadeValue);         
        delay(30);                           
      }
   
      for(byte fadeValue = 255 ; fadeValue >= 0; fadeValue -=5)
      {
        analogWrite(E3, fadeValue);           
        delay(30);                           
      }
      break;
     
      case 5:
      digitalWrite(OUTPUT1, HIGH);
      digitalWrite(OUTPUT3, HIGH);
      for(byte fadeValue = 0 ; fadeValue <= 255; fadeValue +=5)
      {
        analogWrite(E3, fadeValue);         
        delay(30);                           
      }
   
      for(byte fadeValue = 255 ; fadeValue >= 0; fadeValue -=5)
      {
        analogWrite(E3, fadeValue);           
        delay(30);                           
      }
      break;
     
      case 6:
      digitalWrite(OUTPUT2, HIGH);
      digitalWrite(OUTPUT3, HIGH);
      for(byte fadeValue = 0 ; fadeValue <= 255; fadeValue +=5)
      {
        analogWrite(E3, fadeValue);         
        delay(30);                           
      }
   
      for(byte fadeValue = 255 ; fadeValue >= 0; fadeValue -=5)
      {
        analogWrite(E3, fadeValue);           
        delay(30);                           
      }
      break;
     
      case 7:
      digitalWrite(OUTPUT1, HIGH);
      digitalWrite(OUTPUT2, HIGH);
      digitalWrite(OUTPUT3, HIGH);
      for(byte fadeValue = 0 ; fadeValue <= 255; fadeValue +=5)
      {
        analogWrite(E3, fadeValue);         
        delay(30);                           
      }
   
      for(byte fadeValue = 255 ; fadeValue >= 0; fadeValue -=5)
      {
        analogWrite(E3, fadeValue);           
        delay(30);                           
      }
      break;
    }

    digitalWrite(E3, HIGH); // enables outputs

  }
 
 
void loop()
{

  int ran = random(0,7);
  turnOn(ran); 

}

with this code, i can get different led's to turn on by changing the value of the "ran" in "void loop" manually .. ran=5, turns on led Nr 5 .. ect
but when i automate it using the random function, or when using a for-loop going trough led1-led8 .. is doenst work, in this case only one Led is fading ( Led1).

for the other code ( the one you suggested ) ... only led1 is fading. and i cant change the led even when trying different numbers manually
15  Using Arduino / Programming Questions / Re: help with : shiftregister + fading on: June 10, 2011, 06:49:14 pm
Code:
  int OUTPUT1 = 2;
  int OUTPUT2 = 3;
  int OUTPUT3 = 4;
  int E3 = 5;
  int d = 0; // for delay


  void turnOn(int outputPin);

 
  void setup()
  {
    pinMode(OUTPUT1, OUTPUT);
    pinMode(OUTPUT2, OUTPUT);
    pinMode(OUTPUT3, OUTPUT);
    pinMode(E3, OUTPUT);
  }
 
void selectLED(int num) { // select an LED to control
     if(num & 1 !=0) digitalWrite(OUTPUT1, HIGH); else digitalWrite(OUTPUT1, LOW);
     if(num & 2 !=0) digitalWrite(OUTPUT2, HIGH); else digitalWrite(OUTPUT2, LOW);
     if(num & 4 !=0) digitalWrite(OUTPUT3, HIGH); else digitalWrite(OUTPUT3, LOW);
     
     for(byte fadeValue = 0 ; fadeValue <= 255; fadeValue +=5)
      {
        analogWrite(E3, fadeValue);         
        delay(30);                           
      }
   
      for(byte fadeValue = 255 ; fadeValue >= 0; fadeValue -=5)
      {
        analogWrite(E3, fadeValue);           
        delay(30);                           
      }
}
 
 
void loop()
{

  int ran = random(0,7);
  selectLED(ran);

}

is this what you ment ? ( i doubt though .. since i cannot get it to work that way )
Pages: [1] 2 3 ... 6