Hello I desperatly need help with code for running the leddriver to control a ledsegment display. I have hooked it up so it lights up
the driver is this M5482
http://www.datasheetcatalog.org/datasheet2/3/061fj9wgdce6fz72xtkk07ehrgky.pdf
I have tried to write the code using ShiftREgister but i can’t make it show any sense… just random segments lights up.
int bip = 9;
int data = 3;
int clock = 4;
int write_data = 0xFF;
int count = 0;
void setup()
{
pinMode(bip, OUTPUT);
pinMode(data, OUTPUT);
pinMode(clock, OUTPUT);
}
void PulseClock(void) {
digitalWrite(clock, LOW);
delayMicroseconds(20);
digitalWrite(clock, HIGH);
delayMicroseconds(50);
digitalWrite(clock, LOW);
}
void loop() {
// Send config bit.
writeByte(0xFF);
analogWrite(bip,1);
delay(100);
digitalWrite(bip,LOW);
// Send data
writeByte(0xCC);
delay(100);
/*
// Send data
enableOff();
writeByte(0xCC);
writeByte(0xCC);
writeByte(0xCC);
enableOn();
delay(300);
enableOff();
writeByte(0xCC);
enableOn();
enableOff();
writeByte(0xCC);
writeByte(0xCC);
enableOn();
*/
digitalWrite(clock, HIGH);
delay(100);
digitalWrite(clock, LOW);
delay(100);
}
void writeByte(int writeData) {
for (count = 0; count < 35; count++) {
writeBit(writeData & 01);
writeData>>=1;
}
}
void writeBit(boolean bHigh) {
digitalWrite(clock, LOW);
delayMicroseconds(300);
if (bHigh == true) {
digitalWrite(data, HIGH);
}
else {
digitalWrite(data, LOW);
}
// delayMicroseconds(10);
digitalWrite(clock, HIGH);
delayMicroseconds(10);
}
If someone would give it a shot!!