Ive got it completely sorted thanks to Nneil. All Hail Nneil. A true saint.
Thanks to everyone so far...
Decipher this....
3 boards
1 arduino
No Shifters
No Shifting
Custom clock
And some pretty tricky C arrays of arrays.
void setMode(int latchPin){ //sets pins to be outputs, setspins high
int clockPin=latchPin+1;
int dataPin=latchPin+2;
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
digitalWrite(latchPin, 1);
digitalWrite(clockPin, 1);
digitalWrite(dataPin, 1);
}
/*
void shortReset(int latchPin){
int clockPin=latchPin+1;
int dataPin=latchPin+2;
digitalWrite(latchPin, 1); // take the reset pin back hi
delayMicroseconds(60);
digitalWrite(latchPin, 0); // take the reset pin low
delayMicroseconds(60);
digitalWrite(latchPin, 1); // take the reset pin back hi
delay(3);
}
void longReset(int latchPin){
int clockPin=latchPin+1;
int dataPin=latchPin+2;
digitalWrite(latchPin, 1); // take the reset pin back hi
delayMicroseconds(60);
digitalWrite(latchPin, 0); // take the reset pin low
delayMicroseconds(60);
digitalWrite(latchPin, 1); // take the reset pin back hi
delay(3);
}
*/
void sendByte(int latchPin, unsigned int c){ // function sendByte send charactyer to board
int clockPin=latchPin+1;
int dataPin=latchPin+2;
for(int i=7 ; i>=0 ; i--){ // steps thru bits in chars byte - MSB first
digitalWrite(clockPin,1); // clock pin should already be high
digitalWrite(dataPin,(c>>i)&1); // put out appropriate bit for char
delayMicroseconds(100); // min 1 (barmy)
digitalWrite(clockPin,0); // clockingdata into board
delayMicroseconds(100);
digitalWrite(clockPin,1);
}
delayMicroseconds(1000); //inter-byte delay
}
const int d=2000; //long reset (min 2000)
void sendStr(int latchPin, const char * p){ //
int clockPin=latchPin+1; //
int dataPin=latchPin+2;
digitalWrite(latchPin, 0); // take the reset pin low
digitalWrite(dataPin, 0); // & data pin low
delayMicroseconds(d);
digitalWrite(latchPin, 1); // take the reset pin back hi
delayMicroseconds(d);
digitalWrite(dataPin, 1); // data back high
delayMicroseconds(d);
while(*p){ // while char is left in string -
unsigned char c=*p;
if(c>='a' && c<='z') c-='a'-'A';
if(c>='@') c-='@';
//shiftOut(dataPin, clockPin, MSBFIRST, c);
//delayMicroseconds(70);
sendByte(latchPin,c);
p++;
}
delayMicroseconds(d);
}
const int board1=22;
const int board[]={22,26,30};
#define numrows 4 // no of rows of messages MUST MATCH no of rows
const int rowdelay=3; // edit this number for delay time eg 3600 = 1hr
const char * text[numrows][3]= // array of arrays of strings
{
{"a","b","c"}
,{"dog","cat","pig"}
,{"aaa","bbb","ccc"}
,{"doggie","cato","piggy"}
};
void setup(){
setMode(board[0]);
setMode(board[1]);
setMode(board[2]);
}
void loop() {
sendStr(board[0],"BOARD 0"); // board itenitfier sequence
delay(100);
sendStr(board[1],"BOARD 1");
delay(100);
sendStr(board[2],"BOARD 2");
delay(100);
for(int i=0 ; i<=2 ; i++){
sendStr(board[i],"");
delay(100);
}
for(int i=0 ; i< 1; i++){
char str[20];
sprintf(str,"I=%d",i);
sendStr(board[i%3],str);
delay(500); // board itenitfier sequence
}
/////////////////
for(int i=0; i<numrows ; i++){
for(int j=0 ; j<3; j++){
sendStr(board[j],text[i][j]);
}
for(int d=0 ; d<rowdelay ;d++){
delay(1000);
}
}
////////////////////
}