I really want to make a simple alarm clock(for my girlfriend's birthday, day after thanksgiving :/). I have been trying to get this to work for about three days now.I first tried using a MSP430F, but decided to switch to arduino for ease of use.
Please check my code and tell me if I am doing this right. As of right now I got a Arduino Diecimila board, a VFD screen (2 pin power, 2 pin I/O) and a very nice power supply which tells me I am using 5V and 0.05Amps.
Details about the VFD screen.
*NEC D16314AGJ-011 controller, supposed to be the same as HD44780.
*HC 164 - 8 Bit register
*some chip HC00A PAS839. Motorolla symbol. Same size as register.
Datasheet at http://pacerpdfs.s3.amazonaws.com/20T202DA5EB.pdf
The important part of the datasheet:
Now, here is the problem. My VFD displays nothing. I connect everything, I initialize VFD, I write AAAAAAA and BBBBBBB to the VFD, then I tell it to GO, and it is just blank. No backlight, no symbols, nothing.
Can someone please help me with this? I checked everything by now...
Here is my source code:
#define SDA 3
#define CLK 2
#define Both_On PORTD=PORTD & B11110011; // pin 2,3 to 0
#define Both_Off PORTD=PORTD | B00001100; // pin 2,3 to 1
#define Both_Toggle PORTD=PORTD ^ B00001100;
#define SDA_Off PORTD=PORTD & B11110111; //PIN 3 to 0
#define CLK_Off PORTD=PORTD & B11111011; //PIN 2 to 0
#define SDA_On PORTD=PORTD | B00001000; //PIN 3 to 1
#define CLK_On PORTD=PORTD | B00000100; //PIN 2 to 1
#define SDA_Toggle PORTD=PORTD^B00001000;
#define CLK_Toggle PORTD=PORTD^B00000100;
void setup()
{
pinMode(SDA,OUTPUT);
pinMode(CLK,OUTPUT);
}
void sendNibble(byte one, byte two)
{
shiftOut(SDA,CLK,MSBFIRST,one);
CLK_Off
SDA_On
asm volatile("nop\n\t nop\n\t nop\n\t nop\n\t "); //wait for 120+ nS
SDA_Off
asm volatile("nop\n\t nop\n\t nop\n\t nop\n\t "); //120 ns+more
shiftOut(SDA,CLK,MSBFIRST,B00000000); //DUMMY
asm volatile("nop\n\t nop\n\t nop\n\t nop\n\t ");asm volatile("nop\n\t nop\n\t nop\n\t nop\n\t ");
shiftOut(SDA,CLK,MSBFIRST,two);
CLK_Off
SDA_On
asm volatile("nop\n\t nop\n\t nop\n\t nop\n\t ");
SDA_Off
asm volatile("nop\n\t nop\n\t nop\n\t nop\n\t ");
}
void loop() // 0 0 1 r/s
// RST Dummy E r/s
{
delayMicroseconds(100);
sendNibble(B00100011,B00101100); // 0011 1100 Function Set
sendNibble(B00101000,B00100000); // Select top row
for(int i=0;i<16;i++)
sendNibble(B00110100,B00110001); // WRITE AAAAAA 16 times
sendNibble(B00101100,B00100000); // Select Bottom Row
for(int i=0;i<16;i++)
sendNibble(B00110100,B00110010); // Write BBBBBB 16 times
sendNibble(B00100000,B00101100); // Power me ON baby.
// that's it.
delay(10000); // sleep for 10 seconds
sendNibble(B10000000,B10000000); // reset this thing :(
}