Pages: [1]   Go Down
Author Topic: Problems with 4794's in series!!  (Read 430 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 8
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm using an arduino to power two 4794 LED drivers, so I can display digits on my two 7 segment LEDs. Unfortunately, it isn't working properly.

I can display any number, 00-99, but everytime a 1, 4, or 9 shows up on the display on the right a segment is lit up that shouldn't be.

I've checked everything and it seems to be fine. What's wrong!!?

Here's the datasheet for the 4794s:
http://www.nxp.com/acrobat_download/datasheets/HEF4794B_3.pdf

And here's my code:
Code:
int data = 9;
int strob = 8;
int clock = 10;
int oe = 11;
int count = 0;
long dato = 0;

int velocity = 00;
long binaryLED = 0;

void setup()
{
  pinMode(data, OUTPUT);
  pinMode(clock, OUTPUT);
  pinMode(strob, OUTPUT);
  pinMode(oe, OUTPUT);
}

void loop()
{
  convert(velocity);
  segmentWrite();
  velocity++;
  if(velocity==100){velocity=0;}
}

void segmentWrite(){
   dato = binaryLED;
   for (count = 0; count < 16; count++) {
    digitalWrite(data, dato & 01);
    dato>>=1;
    if (count == 15){
    digitalWrite(oe, LOW);
    digitalWrite(strob, HIGH);

    }
    PulseClock();
     digitalWrite(oe, HIGH);
 }

  delayMicroseconds(20);
  digitalWrite(strob, LOW);
  delay(100);


  serialWrite(10);
  serialWrite(13);
 delay(100);                  // waits for a moment
}

void PulseClock(void) {
    digitalWrite(clock, LOW);
    delayMicroseconds(20);
    digitalWrite(clock, HIGH);
    delayMicroseconds(50);
    digitalWrite(clock, LOW);
}

int convert(int number){
     int i = 0;
     int numberl = 0;
     int numberr = 0;

     while(10*i<=number){
       i++;
     }
     numberl = i - 1;
     numberr = number - (10 * numberl);
     binaryLED = 0;
    
     if(numberl==0){
       binaryLED = 32256;
     }else if(numberl==1){
       binaryLED = 4608;
     }else if(numberl==2){
       binaryLED = 48128;
     }else if(numberl==3){
       binaryLED = 46592;
     }else if(numberl==4){
       binaryLED = 53760;
     }else if(numberl==5){
       binaryLED = 58880;
     }else if(numberl==6){
       binaryLED = 60928;
     }else if(numberl==7){
       binaryLED = 12800;
     }else if(numberl==8){
       binaryLED = 65024;
     }else if(numberl==9){
       binaryLED = 61952;
     }
    
     if(numberr==0){
       binaryLED = binaryLED + 126;
     }else if(numberr==1){
       binaryLED = binaryLED + 18;
     }else if(numberr==2){
       binaryLED = binaryLED + 188;
     }else if(numberr==3){
       binaryLED = binaryLED + 182;
     }else if(numberr==4){
       binaryLED = binaryLED + 210;
     }else if(numberr==5){
       binaryLED = binaryLED + 230;
     }else if(numberr==6){
       binaryLED = binaryLED + 238;
     }else if(numberr==7){
       binaryLED = binaryLED + 50;
     }else if(numberr==8){
       binaryLED = binaryLED + 254;
     }else if(numberr==9){
       binaryLED = binaryLED + 242;
     }
    
}
Logged

Pages: [1]   Go Up
Jump to: