#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <math.h>
#include <asm/io.h>


#define CLOCKHI  1 // (Binary 00000001)
#define CLOCKLO  3 // (Binary 00000011)
#define LATCHHI  2 // (Binary 00000010)
#define LATCHLO  3 // (Binary 00000011)



void main(){
  unsigned char bitpattern, x, y; 
    unsigned char bits[16];

 ioperm(0x378,5,1);

 while(1){
  for (x=0;x<16;x++){
    bits[x]=rand()%255;
    printf("%d ", bits[x]);
  }

for (x=0;x<16;x++){   
  bitpattern = bits[x];
  for (y=0;y<8;y++){
    outb(bitpattern & 1,0x378);  
      usleep(1);
    outb(CLOCKHI, 0x037a);
    usleep(10);
    outb(CLOCKLO, 0x37a);   
    usleep(10);  
  bitpattern = bitpattern/2;
      }
 }
   
 outb(LATCHHI, 0x37a);
 usleep(1);
 outb(LATCHLO, 0x37a);
}

   usleep(100);
}

