I’m trying to set up VGA signal timing in the simplest way possible. I’m just trying to display a few simple, still patterns - I’m working on building a custom video adapter and I’m trying to use the Arduino to test out timing. I made a simple sketch that’s supposed to display the left of the screen white and the right black. Pin 10 controls pixels, and is attached to a 4.7kohm resistor that’s attached to the R,G, and B pins of the VGA port. HSYNC and VSYNC are plugged directly into the Arduino’s IO header.
I hooked up a cable to my monitor, and it’s giving me a flashing message box that says the signal is out of range. I think I’ve got some of my timing off, but I’m not sure how to correct it.
Code:
void setup() {
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
digitalWrite(10, LOW); //pin 10 is VSYNC
digitalWrite(9, LOW); //pin 9 is HSYNC
digitalWrite(8, LOW); //pin 8 is pixel data
}
void loop() {
digitalWrite(9, HIGH);
for(int i=0; i<480; i++)
{
digitalWrite(8, HIGH);
delayMicroseconds(12);
digitalWrite(8, LOW);
delayMicroseconds(14);
digitalWrite(9, HIGH);
delayMicroseconds(3.8);
digitalWrite(9, LOW);
delayMicroseconds(1.9);
}
digitalWrite(9, HIGH);
delay(0.45);
digitalWrite(10, HIGH);
delay(0.064);
digitalWrite(10, LOW);
delay(0.02);
digitalWrite(9, LOW);
}
Does anyone know what might be happening? Is delayMicroseconds not precise enough?