Code Repo    |     RSS
MD's Technical Sharing



Wednesday, February 16, 2011

VGA output with PIC Microcontroller

I tried to use the instructions from here to make a PIC16F84A display some test patterns on my monitor. The circuit diagram is simple:

You should try with an old CRT monitor first, which is less sensitive to noises and will not be expensive to replace should you damage it due to connection errors. I tried to build this circuit on a breadboard and found out that it works every time with a CRT monitor but randomly will not work with my LCD monitor - the LCD simply stays in standby mode. Another important thing not mentioned in the article is that the monitor ID (pin #11) has to be grounded to indicate a low-resolution output (VGA 640X480) and the digital ground pin (pin #5) also needs to be grounded. The VGA pinout is detailed below for your reference:

I build the circuit on a veroboard and a breadboard:



Here is the result:
You can display different colors by connecting pin 1 (Red), pin 2 (Green), pin 3 (Blue) or any combinations of these to the 10k resistor.

Here is the horizontal sync and vertical sync signals on my oscilloscope:


Pin 7 output signal vs. horizontal sync:


Pin 7 output after the 10k resistor. The resistor is for brightness adjustment and can be omitted:


Read More »

Wednesday, February 9, 2011

Experimenting with LCD modules and PIC microcontrollers

I recently got a PIC16LF84A (free sample from Microchip) and a few LCD modules at a cheap price from eBay. With some interests and time at hand, I have successfully made these LCD modules work and display some test patterns, just for fun :)

16x2 Character LCD

This LCD is using the standard HD44780 controller so sample source code can be found everywhere on the Internet. I got it to work within 15 minutes:



20x4 Character LCD

This LCD is also using the standard HD44780 controller, but there is more display area, 20 columns and 4 lines. I also got it to work:


Download the source code to test the 16x2 and 20x4 character LCD here.

122x32 Monochrome Graphics LCD

This LCD is using the JHD12232D controller. I purchased it from sure-electronics, an eBay reseller:


Despite being a graphical LCD, its uses are pretty limited due to the small vertical resolution. The 32-pixel vertical resolution is divided into 2 blocks of 16 pixels each, having a space in between. This make it almost impractical to display any bitmaps or graphics on this LCD. The only graphical use for this LCD would be to display Chinese text, as demonstrated in the above picture.

Using the datasheet and sample source code available from the seller website, I am able to make this LCD display some test patterns:


Download the datasheet and source code here
Read More »