Saturday, February 23, 2008

Hacking VGA lines with Arduino

Video URL: http://youtube.com/watch?v=HNJxHzu2NLg

I have been experimenting today with controlling the RGB lines of a VGA connection on a computer monitor using Arduino. The results have been quite promising -- in fact, it was very easy to do and the outcome was considerably better than i had anticipated. In these examples, i am simply using three pins to control the RGB lines. However, the Arduino is not generating horizontal or vertical sync - this is generated by a computer. An extension of this would be to construct a circuit such that each colour data line has a two or three bit DAC controlling the input.

These pictures and the video do not really show all the details.

For me, this is in some ways an extension of the composite video piggy-back noise synthesis stuff i was doing a short while ago.

This project is based largely on an inspirational page on vidiotsquad.com: http://vidiotsquad.com/?page_id=6.


Hardware Connections:




Arduino Code:
byte data1 = 0;
byte data2 = 0;
int dT = 0;

void setup() {
Serial.begin(57600);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
}
void loop() {
if(Serial.available() > 1) {
data1 = Serial.read();
data2 = Serial.read();
}
dT = data2 << 5;
PORTD = data1 << 2;
delayMicroseconds(dT + 1);
PORTD = (255 - data1) << 2;
delayMicroseconds(dT + 1);
}



Max Patch:
Download a version of this patch here: http://milkcrate.com.au/_other/downloads/max_patches/vgahack.pat

Use of this patch will require either the full version of Max/MSP, the Max/MSP Run Time or the Max/MSP 30 day trial.

Let me know if you need this patch changed in some way.


Photos:






17 comments:

bod said...

that was quick seb!

cheers for the link, i like your use of the arduino. its inspired me to dig mine out and try a few things! i briefly managed to get my arduino to produce the vga sync signals without the need for a computer, but the code was dodgy as hell and i cant get it to work properly, and now cant find it at all since my imac died on me.

back to the drawing board.

Sebastian Tomczak said...

Excellent! Wow, that sounds very impressive.

;-)

Good luck with it.

bod said...

not really, it was a botched together code made up of different examples i found on the web, and ultimately it didnt work! ;o)

bod said...

sorry, in case you hadn't guessed, i am mr vidiot.

circuitmaster said...

Did you actually generate the VSync and HSync with the arduino?

Thats the tricky part.

Sebastian Tomczak said...

Oh no, of course not. the sync lines are being controlled by a computer...

Evil Paul said...

Have you seen this project?
It's a VGA monitor tester.

http://www.eosystems.ro/deogen/deogen_en.html

It uses an ATtiny2313 clocked at 20Mhz. It does multiple resolutions even. The ASM source is pretty well commented, as far as I can tell with my limited understanding.

At worst, you could build one and have a pocket sized Hsync+Vsync generator.

Sebastian Tomczak said...

hi paul,
Thanks for the link, yes having a pocket size sync gen would be great.

Nice idea, cheers.

Seb

mikolaj kaczorowski said...

hey seb..for some time i've been fascinated with how a digital camera reads a tv signal...and, artistically, what could be done with this...so it excites me to see you playing with ye olde tv... ..the stuff you've posted looks great...can't wait to see what you conjure up next...good luck

Sebastian Tomczak said...

Oh, hi Mik! Always nice to hear from you. Hope you are going well.

I was thinking that perhaps you might also be into some compositive video noise synthesis... >>

http://little-scale.blogspot.com/2008/01/exploratory-composite-video-noise.html

Mahto said...

Very cool! It is pretty amazing how nice the effect is! Now I am interested in video hacking again...

Anonymous said...

Is it possible to overlay a signal over an existing vga signal so essentially your viewing a normal vid screen with a watermark over the top?

Sebastian Tomczak said...

I don't think so, but I could be wrong of course.

flim said...

hej sebastian!

sorry for asking stupid questions, but is

http://little-scale.blogspot.com/2009/04/how-to-use-arduino-to-generate-glitchy.html

and this blog the same thing? (: if so, what are you up to with the potentiometers?

ps: i've bought a bionicam, but am slowly losing interest.. if you wanna hack that thing somehow - give me a sign! :)

pps: you're blog rocks.

Jonas said...

"An extension of this would be to construct a circuit such that each colour data line has a two or three bit DAC controlling the input."

is that what you've done to create your video - to also change colors with incoming midi signals?

i've copied your circuit in every detail and it works so far - but it all stays in one color.

please help! :)
(i've been tearing my hair over this since morning, hehe)

all the best..!

-jonas

jonas said...

hello sebastian!

have a look at this picture:

http://jonaswolf.com/Arduino_VGA.jpg

i'd like to keep a video running on my mac, which should be visible on my external screen - UNTIL i play a MIDI note. then the usual VGA craziness should take place. as i expected it doesn't work (i only have the VGA craziness).

where's my "lack in logic"?

cheers!

-jonas


ps: ignore the toggle in the picture

pps: you can delete both of my former comments now :)

Anonymous said...

http://www.gammon.com.au/forum/?id=11608