Hi. Control 24V LED strip by Multiplexing. HELP Please!!

Yes a lot better. You have missed the 5V label off the Arduino. The other thing is that the symbol for your LED strip don't show there is a current limiting resistor in the strip.

I am not sure if there is a official symbol for an LED strip. I would propose something like this:-

Bigtimer:
Now I just need help with the Code that will run this bad boy.

Gave you a hint in post#23.
Leo..

Ok so i am finding this really difficult. And really am butchering things together as i have no idea really.

Is this the part of the code that displays the numbers?

void showdigit (int digit)

{
  
 switch (digit) {
 
 case 0:
 digit0 ();
 break;
 
 case 1:
 digit1 ();
 break;
 
 case 2:
 digit2 ();
 break;
 
 case 3:
 digit3 ();
 break;
 
 case 4:
 digit4 ();
 break;
 
 case 5:
 digit5 ();
 break;
 
 case 6:
 digit6 ();
 break;
 
 case 7:
 digit7 ();
 break;
 
 case 8:
 digit8 ();
 break;
 
 case 9:
 digit9 ();
 break;
 
 default:

 
 
 break;
 
 
 
 }; 

};


// showing 4 digits
//  not only shows 4 digit number, but also there is option to turn on
//only selected digits and decimal point.

void showdigits (int number, char digit_on, char  decimal_point) 
{

  

digitalWrite(GND4, LOW);
  // e.g. we have "1234"
showdigit(number/1000);  // segments are set to display "1"
if (decimal_point&8) {digitalWrite(DP, HIGH);} else {digitalWrite(DP, LOW);};
 if (digit_on&8) {
digitalWrite(GND1, HIGH); // first digit on,
digitalWrite(GND2, LOW); // other off
digitalWrite(GND3, LOW);
 }
 delay (1);


number = number%1000;  // remainder of 1234/1000 is 234
digitalWrite(GND1, LOW); // first digit is off
 showdigit(number/100); //// segments are set to display "2"
if (decimal_point&4) {digitalWrite(DP, HIGH);} else {digitalWrite(DP, LOW);};
 if (digit_on&4) {
digitalWrite(GND2, HIGH); // second digit is on
  } delay (1);// and so on....
 
number =number%100;    
digitalWrite(GND2, LOW);
showdigit(number/10);
if (decimal_point&2) {digitalWrite(DP, HIGH);} else {digitalWrite(DP, LOW);};
 if (digit_on&2) {
digitalWrite(GND3, HIGH);
 }
 delay (1);

number =number%10; 
digitalWrite(GND3, LOW);
showdigit(number); 
if (decimal_point&1) {digitalWrite(DP, HIGH);} else {digitalWrite(DP, LOW);};
 if (digit_on&1) {
digitalWrite(GND4, HIGH); 
  }
  delay (1);

};
if (set_mode) {if (Sec==60) {Sec=00;} 

 if (Min==100) {Min=0;} }

      
       else {
 
 if (Sec==-1) {Min--;Sec=59;} 
 
 }  
 
 
//decimal point indication control 

if (!set_mode) {
  
  
  if (!(Sec%2)) { showdigits (Min*100+Sec,0x0F,0x04); } //0X00

else  {showdigits (Min*100+Sec,0x0F,0x00); }; //0000

} else {
  
  if (set_mode==1) {
  
  showdigits (Min*100+Sec,0x0F,0x0C);   //XX00
                                } else { 
                     
                     
                     
                     showdigits (Min*100+Sec,0x0F,0x03);      } //00XX

}
if (run) {  // to do while timer is running; e.g. control relay 
//////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////
digitalWrite(LED, HIGH);


} else digitalWrite(LED, LOW);



if ((Min==0)&&(Sec==0)&&run) {
run=0;
TCCR1B=0x00; //stop timer

How on earth do i translate that into something a shift register can read so fare I have manage to do this .

This is what ive made so fare. don't think it could ever work though.

};
void loop ()

{

for (int Sec=59; Sec>=0; Sec--)
 {
   digitalWrite(latchpin, LOW);
   shiftOut(datapin, clockpin, LSBFIRST, 0); // clears the right display
   shiftOut(datapin, clockpin, LSBFIRST, 0); // clears the left display
   digitalWrite(latchpin, HIGH);
   if (Sec<10)
   {
     digitalWrite(latchpin, LOW);
     shiftOut(datapin, clockpin, LSBFIRST, segdisp[Sec]); // sends the digit down the serial path
     shiftOut(datapin, clockpin, LSBFIRST, 255); // sends a blank down the serial path to push the digit to the right
     digitalWrite(latchpin, HIGH);
   }
   else if (Sec>=10)
   {
     d=Sec%10; // find the remainder of dividing z by 10, this will be the right-hand digit
     c=int(d); // make it an integer, c is the right hand digit
     b=Sec/10; // divide z by 10 - the whole number value will be the left-hand digit
     e = int(b); // e is the left hand digit
     digitalWrite(latchpin, LOW); // send the digits down to the shift registers!
     shiftOut(datapin, clockpin, LSBFIRST, segdisp[c]); 
     shiftOut(datapin, clockpin, LSBFIRST, segdisp[e]); 
     digitalWrite(latchpin, HIGH);
   }
   delay(speed);
 }
 for (int Min=99; Min>=0; Min--)
 {
   digitalWrite(latchpin, LOW);
   shiftOut(datapin, clockpin, LSBFIRST, 0); // clears the right display
   shiftOut(datapin, clockpin, LSBFIRST, 0); // clears the left display
   digitalWrite(latchpin, HIGH);
   if (Min<10)
   {
     digitalWrite(latchpin, LOW);
     shiftOut(datapin, clockpin, LSBFIRST, segdisp[Min]); // sends the digit down the serial path
     shiftOut(datapin, clockpin, LSBFIRST, 255); // sends a blank down the serial path to push the digit to the right
     digitalWrite(latchpin, HIGH);
   }
   else if (Min>=10)
   {
     z=Min%10; // find the remainder of dividing z by 10, this will be the right-hand digit
     q=int(z); // make it an integer, c is the right hand digit
     p=Min/10; // divide z by 10 - the whole number value will be the left-hand digit
     f = int(p); // e is the left hand digit
     digitalWrite(latchpin, LOW); // send the digits down to the shift registers!
     shiftOut(datapin, clockpin, LSBFIRST, segdisp[q]); 
     shiftOut(datapin, clockpin, LSBFIRST, segdisp[f]); 
     digitalWrite(latchpin, HIGH);
   }
   delay(speed);
 }
 


 //////////// button_start//////////

I'm having a look at that code now leo.

how should i implement it?

byte segmentClock = 6;
byte segmentLatch = 5;
byte segmentData = 7;

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

void setup()
{
  Serial.begin(9600);
  Serial.println("Large Digit Driver Example");

  pinMode(segmentClock, OUTPUT);
  pinMode(segmentData, OUTPUT);
  pinMode(segmentLatch, OUTPUT);

  digitalWrite(segmentClock, LOW);
  digitalWrite(segmentData, LOW);
  digitalWrite(segmentLatch, LOW);

  int x = 0;
  while(1)
  {
    if(x == 9)
      postNumber(x, true); //Show decimal
    else
      postNumber(x, false);

    digitalWrite(segmentLatch, LOW);
    digitalWrite(segmentLatch, HIGH); //Register moves storage register on the rising edge of RCK
    delay(500);

    x++;
    x %= 10; //Reset x after 9

    Serial.println(x); //For debugging
  }
}

void loop()
{
  //showNumber(42); //Test pattern
}

//Takes a number and displays 2 numbers. Displays absolute value (no negatives)
void showNumber(float value)
{
  int number = abs(value); //Remove negative signs and any decimals

  //Serial.print("number: ");
  //Serial.println(number);

  for (byte x = 0 ; x < 2 ; x++)
  {
    int remainder = number % 10;

    postNumber(remainder, false);

    number /= 10;
  }

  //Latch the current segment data
  digitalWrite(segmentLatch, LOW);
  digitalWrite(segmentLatch, HIGH); //Register moves storage register on the rising edge of RCK
}

//Given a number, or '-', shifts it out to the display
void postNumber(byte number, boolean decimal)
{
  //    -  A
  //   / / F/B
  //    -  G
  //   / / E/C
  //    -. D/DP

#define a  1<<0
#define b  1<<6
#define c  1<<5
#define d  1<<4
#define e  1<<3
#define f  1<<1
#define g  1<<2
#define dp 1<<7

  byte segments;

  switch (number)
  {
    case 1: segments = b | c; break;
    case 2: segments = a | b | d | e | g; break;
    case 3: segments = a | b | c | d | g; break;
    case 4: segments = f | g | b | c; break;
    case 5: segments = a | f | g | c | d; break;
    case 6: segments = a | f | g | e | c | d; break;
    case 7: segments = a | b | c; break;
    case 8: segments = a | b | c | d | e | f | g; break;
    case 9: segments = a | b | c | d | f | g; break;
    case 0: segments = a | b | c | d | e | f; break;
    case ' ': segments = 0; break;
    case 'c': segments = g | e | d; break;
    case '-': segments = g; break;
  }

  if (decimal) segments |= dp;

  //Clock these bits out to the drivers
  for (byte x = 0 ; x < 8 ; x++)
  {
    digitalWrite(segmentClock, LOW);
    digitalWrite(segmentData, segments & 1 << (7 - x));
    digitalWrite(segmentClock, HIGH); //Data transfers to the register on the rising edge of SRCK
  }
}

Use the first example.
The example has a 2-digit counter (which you don't need).
But ok to see it all working.

Change
number %= 100; //Reset x after 99
to
number %= 10000; //Reset x after 9999 for your 4-digit display

Then snip out the counter part, and only use
showNumber(number); // displays the value of 'number'

Get the hardware done first, then worry about the software.
Leo..

Hi

i'm still waiting for my Tpic6b595 to arrive hopefully they come tomorrow .

in the meantime I found this code on the arduino forum i think will work.

Arfuino Forum page

// Boffin1's  countdown " bomb " timer with preset up down run and pause
//   connect dots  to spare TPIC output on minute units chip, on when counting down, flash when paused
#include <VirtualWire.h>
#define latchPin 19  // rck
#define clockPin 18  // sck
#define dataPin 16   // ser in

int tile [4];
//  bitmap for which leds segements ( TPIC pins ) are lit for numbers 0 - 9, first bit for dots
// this pattern will depend on how the segments are wired up
//       this pattern is for  sequence   =   dots,  e,  d,  c,  g,  b,  f,  a
const byte digitTable [10] = { 
 B01110111, B00010100, B01101101, B00111101, B00011110, B00111011, B01111011, B00010101, B01111111,B00111111 } 
;   

const byte blanked = B00000000; 
int dotState;
int pause = HIGH;
int blank = HIGH;
int mintens = 0;
int minunits = 0;
int sectens = 0;
int secunits = 0;
int timeleft = 0;              
unsigned long previousdotMillis = 0;  
unsigned long previousMillis = 0;     
int mintendisp; 
int minunitsdisp;
int sectensdisp;
int secunitsdisp;  
int plusPin = 4;
int minusPin = 5;
int runPin = 6;
int pausePin = 7;
int running;
int bombPin = 8;

//******************************************************        
void setup()
{
 Serial.begin(9600);  
 blank == HIGH;
 Serial.println("setup");
 pinMode ( latchPin, OUTPUT);
 pinMode ( clockPin, OUTPUT);
 pinMode ( dataPin, OUTPUT); 
 pinMode ( plusPin, INPUT); 
 digitalWrite(plusPin, HIGH); // set pullups
 pinMode ( minusPin, INPUT); 
 digitalWrite(minusPin, HIGH);
 pinMode ( runPin, INPUT); 
 digitalWrite (runPin, HIGH);
 pinMode ( pausePin, INPUT); 
 digitalWrite(pausePin, HIGH);

 digitalWrite(latchPin, LOW);      // blanking all displays
 for ( int k=0; k<=3; k++ ){
   shiftOut(dataPin, clockPin, LSBFIRST, blank); 
   delay (5);
 }
 digitalWrite(latchPin, HIGH);  
 pinMode ( bombPin, INPUT); 
 digitalWrite(bombPin, LOW);
}
//********************************************************************
void loop () 
{  

 checktime();

 if ( mintens + minunits + sectens + secunits  >= 1 ){ 
   timeleft = HIGH;
 }    // check again after countdown
 else 
 { 
   timeleft = LOW ; 
   pause = HIGH;   
 }     //  flashing dots
 unsigned long currentdotMillis = millis();
 if(currentdotMillis - previousdotMillis > 500) {
   previousdotMillis = currentdotMillis;    
   if (dotState == LOW)
   {
     dotState = HIGH;
   }    
   else     { 
     dotState = LOW;
   }  
   showtime ();
 }
 if ( pause == LOW ) { 
   dotState = HIGH ;
 }

 

 checkbutton ();    


}//  end of loop


void checktime () {
 if ( mintens + minunits + sectens + secunits  >= 1 )  //  if time still left on countdown
 { 
   timeleft = HIGH;
 } 
 else { 
   timeleft = LOW ; 
   pause = HIGH; 
 }

 if (timeleft == HIGH ) {
   if ( pause == LOW ) {  //  which means its counting down   i.e. not paused in countdown          
     static unsigned long previousMillis;
     if(millis() > previousMillis)
     { 
       previousMillis = millis() + 1000; 
       secunits -- ;             // countdown 1 sec 
       if ( secunits  < 0 ){ 
         secunits = 9;  
         sectens -- ;
       }
       if ( sectens   < 0 ){ 
         sectens = 5;  
         minunits -- ;
       }
       if ( minunits  < 0 ){ 
         minunits = 9;  
         mintens -- ;
       } 
       // mintens cant get to -1 or it would have to have been 0000 and paused
       Serial.print(mintens);  
       Serial.print(minunits);  
       Serial.print(" : "); 
       Serial.print(sectens);  
       Serial.println(secunits); 
       showtime ();

       if ( mintens + minunits + sectens + secunits  >= 1 ){ 
         timeleft = HIGH;
       } 
       else { 
         digitalWrite( bombPin, HIGH ) ; 
         timeleft = LOW ; 
         pause = HIGH ;
                // milliseconds bombPin goes high
         delay ( 2000 ); 
       } 
       digitalWrite( bombPin, LOW );

     } 
     dotState = HIGH; 
   } // keeps dots on while countdown 
   else 
     if ( blank == LOW ) {
     flashdots ();
   }

 }
} // END OF CHECKTIME

void checkbutton ()
{   
 int plus = digitalRead( plusPin );
 if ( plus == LOW ) {     
   secunits ++;  
 }  

 if ( secunits > 9 ){       
   secunits = 0 ;       
   sectens ++;    
 } 
 if ( sectens >5 ) {      
   sectens = 0;      
   minunits ++;    
 }
 if ( minunits > 9 ){      
   minunits=0;       
   mintens ++;    
 }
 if ( mintens >5 ){       
   mintens = 0 ;    
 }   

 int minus = digitalRead( minusPin );
 if ( minus == LOW ) {  
   secunits --; 
 }

 if ( secunits  < 0 ){       
   secunits = 9;        
   sectens -- ;    
 }
 if ( sectens   < 0 ){       
   sectens = 5;       
   minunits -- ;    
 }
 if ( minunits  < 0 ){       
   minunits = 9;        
   mintens -- ;    
 }  
 if ( mintens < 0 ){        
   mintens =5 ;     
 }

 //  CHANGE THIS DELAY TO SET COUNTSPEED WHEN + or - BUTTON HELD IN
 if ( plus || minus == LOW ){  
   delay ( 100 ) ;     
   showtime ();      
 }  


 // when run button pressed release pause
 int runbutton = digitalRead( runPin );
 if ( runbutton == LOW ) { 
   pause = LOW ; 
 } 


 // when pause button pressed  set pause
 int pausebutton  = digitalRead( pausePin );  
 if ( pausebutton == LOW ) { 
   pause = HIGH ; 
 } 



}  // end of checkbutton function 

void flashdots () { 
 unsigned long currentdotMillis = millis();
 if(currentdotMillis - previousdotMillis > 500) {
   previousdotMillis = currentdotMillis;    
   if (dotState == LOW)
   {
     dotState = HIGH;
   }
   else  { 
     dotState = LOW;
   }     
   showtime ();  
 }
 if ( pause == LOW ) { 
   dotState = HIGH ;
 }  
} //  end of flashdots routins 

void showtime ()   //  DISPLAY ROUTINE 
{   
 int mintendisp = (mintens) ? digitTable [ mintens ] : 0;  //  zero blanking tens minutes
 int minunitsdisp = digitTable [ minunits ];
 int sectensdisp = digitTable [ sectens ];
 int secunitsdisp = digitTable [ secunits ];
 if ( dotState == HIGH ){

   minunitsdisp = minunitsdisp|10000000 ; 
 }      //   adds msb to minunit to light dots when dotState high

 digitalWrite(latchPin, LOW); 

 shiftOut(dataPin, clockPin, LSBFIRST, mintendisp);
 shiftOut(dataPin, clockPin, LSBFIRST, minunitsdisp);
 shiftOut(dataPin, clockPin, LSBFIRST, sectensdisp); 
 shiftOut(dataPin, clockPin, LSBFIRST, secunitsdisp);

 digitalWrite(latchPin, HIGH);
}

Maybe your can use some lines of code from that sketch, but most of it is pretty lousy.

So i have just run my circuit for the fist time now I have the Chips, I ran it with that code with just one display connected, and the display started to flashing on and off which i supposes means that something is working at least.

how-ever the bad new is one of my 47uF capacitors went BOOM!!! lol

any ideas why this could be?

it had 24v going through it?

The capacitor will go boom if the rating voltage is less than the 24V you are putting across it.

It will also go boom if you connected it the wrong way round.

There is not much of it left to see which one it was.

16v its says on it

do you guys know of any simple count down code that i could use just to test this thing. i have no idea how to code it

So the Sparkfun countUP code I linked to doesn't work?

int number = 0;
change that to
int number = 9999;
and
number++;
to
number--;
for a 4digit count down display.
Leo.

ok ive done that. using the code of sparkfun that you said.

but it is not printing numbers. it is just turning each LED segment on one after another.

Here is the test sketch I am using at the moment while I construct my 7-seg display:

#include <SPI.h>

#define LATCH D8

SPISettings tpic6c595(10000000UL, MSBFIRST, SPI_MODE0);

byte digitPattern[10] = {
  0b0111111,
  0b0000110,
  0b1011011,
  0b1001111,
  0b1100110,
  0b1101101,
  0b1111101,
  0b0000111,
  0b1111111,
  0b1101111
};

void setup() {
  pinMode(LATCH, OUTPUT);
  Serial.begin(115200);
  SPI.begin();
  SPI.beginTransaction(tpic6c595);
}

void loop() {
  for (int i = 0; i <= 9; i++) {
    SPI.transfer(digitPattern[i]);
    digitalWrite(LATCH, HIGH);
    digitalWrite(LATCH, LOW);
    delay(500);
  }

}

Bigtimer:
16v its says on it

So now you know why it went boom when you connected it to 24V

Hi guy’s hope you are all doing well. Yes I think figured out 'Boom Boom' haha

I have final got to point where I think I am beginning to make some progress. Problem is my deadline for this project is tomorrow, so as crap as the code is at the moment, it works to sum degree. I will come back to it very soon to make it the best it can be But for now it will do.

I final managed to make the clock display numbers. Turns out it was the Boolen numbers are back to front ‘0’ would turn the display on and ‘1’ it off so once I swooped them all around I had a clock that would count up.

Now all I had to do was make it count down. I’m sure there is a supper easy way to do this but I just couldn’t figure it out.

Something like for(int i=0; ,i>=0; i--)

But when I tried that nothing happened

So what I have done is reversed the order in which the boolen numbers are in to to count up backwards ‘LOL’ {9, 8 ,7, 6, 5, 4, 3 ,2, 1, 0,} I know its crude but it works

#define LATCH 6
#define DATA 7
#define CLK 5

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=



//This is the hex value of each number stored in an array by index num

byte digitOne[10]= {B00011001, B00000001, B01111001, B00000011, B00010011, B10011001, B01010001, B01000101, B11111001, B00100001};

byte digitTwo[10]= {B00011001, B00000001, B01111001, B00000011, B00010011, B10011001, B01010001, B01000101, B11111001, B00100001};

byte digitThree[6]= { B00010011, B10011001, B01010001, B01000101, B11111001, B00100001}; // online 6 number for the minets 

byte digitFour[10]= {B00011001, B00000001, B01111001, B00000011, B00010011, B10011001, B01010001, B01000101, B11111001, B00100001};


int i;

void setup(){
 
  pinMode(LATCH, OUTPUT);
  pinMode(CLK, OUTPUT);
  pinMode(DATA, OUTPUT);

   
   
}

void loop(){
//  Count down

    for(int l=0; l<10; l++){
  for(int k=0; k<10; k++){ 
    for(int j=0; j<6; j++){
  for(int i=0; i<10; i++){
   
     
        
      digitalWrite(LATCH, LOW);
      shiftOut(DATA, CLK, LSBFIRST, ~digitFour[i]); // digitTwo
      shiftOut(DATA, CLK, LSBFIRST, ~digitThree[j]); // digitOne
      shiftOut(DATA, CLK, LSBFIRST, ~digitTwo[k]); // digitTwo
      shiftOut(DATA, CLK, LSBFIRST, ~digitOne[l]); // digitOne
      digitalWrite(LATCH, HIGH);
      delay(5);

      if(i+j+k+l);=0{ // this code dose not work im not sure why 
       digitalWrite(LATCH, LOW);
      shiftOut(DATA, CLK, LSBFIRST, B11111111,); // digitTwo
       digitalWrite(LATCH, HIGH)
       delay(1000000);
        
      }
    }
  }
    }
  }
} 

//That's all for shift registers!

Now all I need is a little bit of to stop the clock when it gets to ‘0’ so It doesn't go 99:99 agiain

Also a little bit of code to start the clock of in the first place would be nice. Like a push to start button.

Hope you Guys can help me with this final task, would be much appreciated

if(i+j+k+l);=0{ // this code dose not work im not sure why

Because the if statement is not correct. Do you mean

if(i+j+k+l=0){

Something like for(int i=0; ,i>=0; i--)

No, just read what it says.

Set the variable i to be zero
While the variable i is greater than zero do what is in the block following the "if" :- now as i is set to zero it can never be greater than zero so the statements after the "if" can never be run.