Friday, March 30, 2012

GIMP: Adding New .gpl Palette

Palettes are very useful if you want to have a consistent color scheme. I find that having good colors readily available helps in the creative process as well. You can find great user-created palettes for free at (link) and (link); using these palettes can give your project a very professional look.

Palette dialog

The easiest way to import a palette is to simply drop the file in the the file system GIMP created when it was installed. On Windows XP, the file would be: C:\Documents and Settings\<fill in user name>\.gimp-2.6\palettes. On Mac OS X, it would be: Users/homefolder/library/applicationsupport/ GIMP/palettes. I am not familiar with the location on other operating systems but if you look around a bit it should be obvious. Note that the file must have the file the extension .gpl to work. Also, you must restart GIMP for the palette to show up.

An alternate way to add palettes is to use the user interface. Since this does not depend on the file structure, it should be valid for all operating systems. From the image window, go to Windows>Dockable Dialogs>Palettes and click to open the Palettes dialog. On the Palettes dialog, click on the little arrow on the top right. This brings up a menu where you go Palettes Menu>Import Palette. From here, you simply select "palette file" as the source and browse to the desired .gpl file.

FYI, I used GIMP 2.6.11 for this tutorial.

Import New Palette dialog

Wednesday, March 21, 2012

Arduino: Sending Hex Bytes to Serial Devices

I have been working on a project which involves an Arduino communicating serially with an LCD display device. Through a lot of trial and error, I finally figured out that when you want to send a HEX-encoded byte from the Arduino, you need to use the Serial.write() command rather than the Serial.print() command. The Serial.print() command works find when you are sending an ASCII byte but it will not work when you try to send a HEX byte. The right and wrong ways are below:
//Serial.print('U');  <----right (ASCII)
//Serial.write('U');  <----also fine (ASCII)
//Serial.print(0x55); <----WRONG! (HEX)
//Serial.write(0x55); <----right (HEX)

Similar problem and solution:

Thursday, March 1, 2012

STK 200: First Program (LED Blink)

For this program, you should already have AVR Studio 5 and AVRISP-U installed on your computer. If you don't, visit my previous post Getting Started Programming Guide (link). This is a simple program which simply makes the built-in LEDs to blink. I'm going to use C for this program because the code looks really simple. The assembly version is not really difficult either but we'll keep it simple for now. Note that AVR Studio 5 has a built-in C compiler. You might remember for AVR Studio 4, you had to download AVR GCC and integrate it. If you downloaded AVR Studio 5, you already have the C compiler.

What will the program do? If you look at the STK 200, there is a row of 10 LEDs numbered from 0 to 7 then "ISP" and "ON." These are the built-in LEDs. Our program will make the LEDs numbered from 0 to 7 blink on and off at a rate perceptible to the human eye. In microcontroller terms, this means physically connecting the LEDs to PORTB and sending alternating HIGH/LOW signals to PORTB. Note that is all output - no input. If you don't know what PORTB is, check my Basic Layout Guide (link).

Step 1 - Create a new project: Go ahead and open AVR Studio 5. From the startup screen, go to File>New>Project... and you should see a New Project dialog box. At the top left of the dialog box, select the C templates and then choose "C Executable Project" in the middle of the screen. At the bottom, fill in "blink" as the name and this should automatically fill the solution name field with the same text. Also, make sure that the "Create directory for solution" box is checked. This checkbox will not affect your code at all, but it will keep your AVRStudio folder better organized. Look at the picture below and make sure your screen looks the same:
STK 200: New Project Dialog Box