Hello,
I'm trying to get New Haven Display's M0116MY-161LSBR2-S2 VFD to function with an arduino. As a test sketch, I tried to print nothing the letter 'A' all the way across the screen following the timing specs in the datasheet. My code is below:
int clockPin = 6;
int dataPin = 7;
int data[8] = {
0,0,0,0,0,0,0,0};
int data2[8] = {
0,0,0,0,0,0,0,1};
void setup() {
Serial.begin(9600);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
digitalWrite(clockPin, 0);
writeByte(0xAF);
writeByte(0xC0);
writeByte(0xF0);
}
void loop() {
writeByte(0x00);
writeByte(0x01);
writeByte(0x02);
writeByte(0x03);
writeByte(0x04);
writeByte(0x05);
writeByte(0x06);
writeByte(0x07);
writeByte(0x08);
writeByte(0x09);
writeByte(0x0A);
writeByte(0x0B);
writeByte(0x0C);
writeByte(0x0D);
writeByte(0x0E);
writeByte(0x0F);
delay(1000);
clearBuffer();
delay(1000);
}
void writeByte(int value) {
for (int i = 0; i < 8; i++) {
//set clock to HIGH, wait 5 us
digitalWrite(clockPin, 1);
//delayMicroseconds(5);
//write data, bit by bit, and wait 5 more microseconds
digitalWrite(dataPin, (value >> i) & 0x01);
delayMicroseconds(5);
//set clock to low, wait 5 us
digitalWrite(clockPin, 0);
delayMicroseconds(5);
}
//between words, wait longer
delayMicroseconds(60);
}
void clearBuffer() {
for(int i = 0; i < 16; i++) {
writeByte(0x20);
}
}
However, this just provides a garbled mess of letters. I've tried other letters, and only "@" seems to work, but that's probably because the character code is 0x00, so the timing doesn't matter for that. Am I approaching inputting the data/clock the wrong way, or is this a reasonable approach? Is it just an issue with the timing somewhere?
I've attached the data sheet for easy reference.
thanks!
M0116MY-161LSBR2-S2.pdf (1.29 MB)