#define VFD_in 7 // This is the pin number 7 on Arduino UNO
#define VFD_clk 8 // This is the pin number 8 on Arduino UNO
#define VFD_ce 9 // This is the pin number 9 on Arduino UNO
//ATT: On the Uno and other ATMEGA based boards, unsigned ints (unsigned integers) are the same as ints in that they store a 2 byte value.
//Long variables are extended size variables for number storage, and store 32 bits (4 bytes), from -2,147,483,648 to 2,147,483,647.
//*************************************************//
void setup() {
pinMode(VFD_clk, OUTPUT);
pinMode(VFD_in, OUTPUT);
pinMode(VFD_ce, OUTPUT);
pinMode(13, OUTPUT);
Serial.begin(9600); // only to debug
}
void send_char(unsigned char a)
{
//
unsigned char transmit = 15; //define our transmit pin
unsigned char data = 170; //value to transmit, binary 10101010
unsigned char mask = 1; //our bitmask
data=a;
// the validation of data happen when clk go from LOW to HIGH.
digitalWrite(VFD_ce, LOW); // When strobe is low, all output is enable. If high, all output will be set to low.
delayMicroseconds(5);
digitalWrite(VFD_clk,LOW);// need invert the signal to allow 8 bits is is low only send 7 bits
delayMicroseconds(5);
for (mask = 0b00000001; mask>0; mask <<= 1) { //iterate through bit mask
digitalWrite(VFD_clk,LOW);// need invert the signal to allow 8 bits is is low only send 7 bits
delayMicroseconds(5);
if (data & mask){ // if bitwise AND resolves to true
digitalWrite(VFD_in, HIGH);
//Serial.print(1);
}
else{ //if bitwise and resolves to false
digitalWrite(VFD_in, LOW);
//Serial.print(0);
}
digitalWrite(VFD_clk,HIGH);// need invert the signal to allow 8 bits is is low only send 7 bits
delayMicroseconds(5);
//
digitalWrite(VFD_ce, HIGH); // When strobe is low, all output is enable. If high, all output will be set to low.
delayMicroseconds(5);
}
}
/*********************************************************************/
// I h've created 3 functions to send bit's, one with strobe, other without strobe and one with first byte with strobe followed by remaing bits.
void send_char_without(unsigned char a)
{
unsigned char transmit = 15; //define our transmit pin
unsigned char data = 170; //value to transmit, binary 10101010
unsigned char mask = 1; //our bitmask
data=a;
for (mask = 0b00000001; mask>0; mask <<= 1) { //iterate through bit mask
digitalWrite(VFD_clk, LOW);
delayMicroseconds(5);
if (data & mask){ // if bitwise AND resolves to true
digitalWrite(VFD_in, HIGH);
//Serial.print(1);
}
else{ //if bitwise and resolves to false
digitalWrite(VFD_in, LOW);
//Serial.print(0);
}
digitalWrite(VFD_clk,HIGH);// need invert the signal to allow 8 bits is is low only send 7 bits
delayMicroseconds(5);
}
}
/*********************************************************************/
void send_char_8bit_stb(unsigned char a)
{
unsigned char transmit = 15; //define our transmit pin
unsigned char data = 170; //value to transmit, binary 10101010
unsigned char mask = 1; //our bitmask
int i = -1;
data=a;
for (mask = 0b00000001; mask>0; mask <<= 1) { //iterate through bit mask
i++;
digitalWrite(VFD_clk, LOW);
delayMicroseconds(5);
if (data & mask){ // if bitwise AND resolves to true
digitalWrite(VFD_in, HIGH);
//Serial.print(1);
}
else{ //if bitwise and resolves to false
digitalWrite(VFD_in, LOW);
//Serial.print(0);
}
digitalWrite(VFD_clk,HIGH);//
delayMicroseconds(1);
if (i==7){
Serial.println(i);
digitalWrite(VFD_ce, HIGH);
delayMicroseconds(1);
}
}
}
/*******************************************************************/
void allON_LC75823(){
unsigned char group=0;
//send total of 56 bits (7Bytes), the 4 last 14 bits belongs to controls
//The p0, p1, p2 & p3 at 0, means all pins from s1 to s12 will belongs to segments, other's settings tell will px is a port general purpose!
for(int i=0; i<3;i++){ // Dx until 164 bits
group=i;
digitalWrite(VFD_ce, LOW); //
delayMicroseconds(1);
// Position of bit(..76543210)
send_char_8bit_stb(0B01000001); //(0x41) firts 8 bits is address, every fixed as (0B01000001), see if clk finish LOW or HIGH Very important!
delayMicroseconds(1);
// On the 75878 the message have first 16*8 bits more 8 times to performe 128 bits(last byte is control: 0BXXX00000)
send_char_without(0B11111111); send_char_without(0B11111111); // 1:8 -9:16//
send_char_without(0B11111111); send_char_without(0B11111111); // 17:24 -25:32//
send_char_without(0B11111111); send_char_without(0B11111111); // 33:40 -41:48//
send_char_without(0B11111111); send_char_without(0B11111111); // 49:56 -57:64//
send_char_without(0B11111111); send_char_without(0B11111111); // 65:72 -73:80//
send_char_without(0B11111111); send_char_without(0B11111111); // 81:88 -89:96//
send_char_without(0B11111111); send_char_without(0B11111111); // 97:104 -105:112//
send_char_without(0B11111111); send_char_without(0B11111111); // 113:120 -121:128//
send_char_without(0B11111111); send_char_without(0B11111111); // 120:136 -137:144//
send_char_without(0B11111111); send_char_without(0B00011111); // 145:152 -153:160//
delayMicroseconds(1);
digitalWrite(VFD_ce, LOW); //
delayMicroseconds(1);
}
}