Тема: PT6523 — ЖКИ драйвер (Arduino)
http://rcl-radio.ru/wp-content/uploads/ … PT6523.pdf
#define DELAY 200
#define CE 3
#define CL 4
#define DI 2
unsigned long t=0b10000000000000000000000000000000;// 32 bit
unsigned long t1=0b1000000000000000000000000000; // 28 bit
void setup() {
Serial.begin(9600);
pinMode(CE, OUTPUT);
pinMode(CL, OUTPUT);
pinMode(DI, OUTPUT);
digitalWrite(CE,LOW);
digitalWrite(CL,LOW);
delay(200);
// 1 32
//byte_1 00000000000000000000000000000000
// 33 64
//byte_2 00000000000000000000000000000000
// 65 96
//byte_3 00000000000000000000000000000000
// 97 128
//byte_4 00000000000000000000000000000000
// 129 156
//byte_5 0000000000000000000000000000
}
void loop() {
write_byte(0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0B1111111111111111111111111111,0b0000);
delay(5000);
for(int j=0;j<=31;j++){
write_byte(t>>j,0,0,0,0,0b0000);
Serial.print(t>>j,BIN); Serial.print(" bit "); Serial.println(j+1);
delay(DELAY);
}
for(int j=0;j<=31;j++){
write_byte(0,t>>j,0,0,0,0b0000);
Serial.print(t>>j,BIN); Serial.print(" bit "); Serial.println(j+33);
delay(DELAY);
}
for(int j=0;j<=31;j++){
write_byte(0,0,t>>j,0,0,0b0000);
Serial.print(t>>j,BIN); Serial.print(" bit "); Serial.println(j+65);
delay(DELAY);
}
for(int j=0;j<=31;j++){
write_byte(0,0,0,t>>j,0,0b0000);
Serial.print(t>>j,BIN); Serial.print(" bit "); Serial.println(j+97);
delay(DELAY);
}
for(int j=0;j<=27;j++){
write_byte(0,0,0,0,t>>j,0b0000);
Serial.print(t1>>j,BIN); Serial.print(" bit "); Serial.println(j+129);
delay(DELAY);
}
}
void write_byte( unsigned long b0, unsigned long b1, unsigned long b2, unsigned long b3, unsigned long b4, byte contr){
/// addr 8 bit
digitalWrite(CE,LOW);delayMicroseconds(10);
for(int i = 0; i <= 7; i++){
digitalWrite(CL,LOW);delayMicroseconds(10);
digitalWrite(DI, (0x41 >> i) & 1);
digitalWrite(CL,HIGH);delayMicroseconds(10);
}
digitalWrite(CL,LOW);delayMicroseconds(10);
digitalWrite(CE,HIGH);delayMicroseconds(10);
// data 156 bit
// 1-24 seg
for(int i = 31;i >= 0; i--){
digitalWrite(CL,LOW);delayMicroseconds(10);
digitalWrite(DI, (b0 >> i) & 1);
digitalWrite(CL,HIGH);delayMicroseconds(10);
}
for(int i = 31;i >= 0; i--){
digitalWrite(CL,LOW);delayMicroseconds(10);
digitalWrite(DI, (b1 >> i) & 1);
digitalWrite(CL,HIGH);delayMicroseconds(10);
}
for(int i = 31;i >= 0; i--){
digitalWrite(CL,LOW);delayMicroseconds(10);
digitalWrite(DI, (b2 >> i) & 1);
digitalWrite(CL,HIGH);delayMicroseconds(10);
}
for(int i = 31;i >= 0; i--){
digitalWrite(CL,LOW);delayMicroseconds(10);
digitalWrite(DI, (b3 >> i) & 1);
digitalWrite(CL,HIGH);delayMicroseconds(10);
}
for(int i = 27;i >= 0; i--){
digitalWrite(CL,LOW);delayMicroseconds(10);
digitalWrite(DI, (b4 >> i) & 1);
digitalWrite(CL,HIGH);delayMicroseconds(10);
}
// control data 4 bit
for(int i = 3; i >= 0; i--){
digitalWrite(CL,LOW);delayMicroseconds(10);
digitalWrite(DI, (contr >> i) & 1);
digitalWrite(CL,HIGH);delayMicroseconds(10);
}
digitalWrite(CE,LOW);
digitalWrite(CL,LOW);
delay(1);
}