(I'm sorry for my bad English, but I will do my best)
I have a Chinese MUC which already programmed. It communicates with a LED driver chip using three wires (STB,CLK,DIN).
(LED driver controls 16 digit 7 Segment display)
After some research, I found that it can be talk to LED driver using shiftout function.
Now the main coal is to connect these 3 pins(STB,clk,din) to Arduino and read the incoming data and convert the data to numbers.
To test if this idea is working or not,
I came with two arduino (uno to send shiftout function and mega to read it) after connect pin 2 of uno to pin 2 of mega and same 3 to 3, 4 to 4 and also Gnd of uno to Gnd of mega.
I wrote these codes:
arduino UNO side (to send shiftOut function)
#define STB 4
#define clockPin 5
#define dataPin 6
void setup() {
Serial.begin(9600);
pinMode(STB, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}
void loop() {
digitalWrite(STB, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, 0b10101010 ); // 1st digit
digitalWrite(STB, HIGH);
}
arduino mega side (to read shiftOut function)
#define STB 4
#define clockPin 5
#define dataPin 6
int R_STB[8];
int R_clockPin ;
int R_dataPin ;
void setup() {
Serial.begin(115200);
pinMode(STB, INPUT);
pinMode(clockPin, INPUT);
pinMode(dataPin, INPUT);
}
void loop() {
R_STB = digitalRead(STB);
R_clockPin = digitalRead(clockPin);
R_dataPin = digitalRead(dataPin);
for(int i=0 ; i<8;i++){
Serial.print(R_STB[i]-2);
Serial.print(" ");
Serial.print (R_clockPin[i]);
Serial.print(" ");
Serial.print(R_dataPin[i]+2);
Serial.println(" ");
}
}
But the digital read at arduino mega side can't read all data due to it fast switching between High LOW statement maybe? and I am stuck here.
Please any one has any ideas?