Saturday, April 28, 2012

HD44780 Custom Character Generator - Update

Yeaaaaaaaaaaa, HD44780 CCG  gets an update

I've added a Menu which enables saving and loading



you can save files in "ccg" extensions

here is an example "HappyFace.ccg"





Download the new version (V1.001) of HD44780 Custom Character Generator

github: https://github.com/MuazSalah/HD44780_CCG

Friday, April 27, 2012

HD44780 Custom Graphics Generator

Previously, I used to use Sparkfun's serial LCD, which is really neat and very easy to use, however, it is a lil buggy sometimes and the PCB takes wider space. So, I decided to go back in time and use the bare LCD with HD44780 controller (also I got it from sparkfun).

So After I got it, my plan was to write my own code to drive it, but then my laziness beat my excitness :P

Searching in the web, I came across this really awesome and very easy to use library from Peter Fleury to drive the LCD which I tried and liked. It is really awesome to get started with these LCDs

On the example code, he shows how easy it is to create a custom character eg.: the Copyright symbol by simply defining the 0s and 1s (for this specific example two character cells are required, hence two lines)


static const PROGMEM unsigned char copyRightChar[] =
{
    0x07, 0x08, 0x13, 0x14, 0x14, 0x13, 0x08, 0x07,
    0x00, 0x10, 0x08, 0x08, 0x08, 0x08, 0x10, 0x00
};


so I decided to make it even easier, I made a visual basic program :)



you only need to dray on the Image area by clicking on individual pixels


The result is displayed on the Preview area, and the actual code is on the text box, very simple!




same as the above picture but inverted :D

It doesn't look like a heart? yea, excuse my drawing abilities






yea, Arabic as well :D

You can download the program form here


Saturday, April 21, 2012

Push Button ON/OFF

21st April, 2012

Ever wondered how can you keep your circuit ON using a push button rather than a toggling switch?

just like in many instruments/ mobile phones etc

the following schematic shows you how,


The idea is that you use the push button to run the circuit normally, and then, very fast (in the beginning of your code if the cct contain a microcontroller) send a signal to close a switch (could be a relay or whatever)

Example on ATmega328

#include <avr/io.h>  
#include <util/delay.h>  
#include <USART.h>  
#define SETBIT(ADDRESS,BIT) (ADDRESS |= (1<<BIT))  
#define CLEARBIT(ADDRESS,BIT) (ADDRESS &= ~(1<<BIT)) 

int main(void)  
{  
    init_usart();  
    SETBIT(DDRB,0);  //Output pin (ON/OFF)
    CLEARBIT(DDRB,1); //Input to change time
    SETBIT(PORTB,1);  //Enable Pull-Up resistor

    for (;;)  
    {  
        for (uint16_t i=30; i>0; i--)  //repeat 15 times going down, used as delay
        {  
            printf("i=%d\n",i);  //just to see whats the current delay value
            _delay_ms(100);  //give me time to release button
            while ((PINB & 0x02)==0x02)  //loop when I don't press button
            {  
                SETBIT(PORTB,0);   //ON
                _delay_ms(i);      //i value as delay
                CLEARBIT(PORTB,0); //OFF 
                _delay_ms(i);
            }  
        }  
    }  
    return 0;  
} 


Remember that when a person pushes a button and releases it, he usually takes quite long (in ms), which is an enough time for the MCU to run, turn the switch ON and keep itself alive :)








26th April, 2012

So I've tried to go with only MOSFETs instead of the bulky relay, I tried this earlier:




which did not succeed as I said, so today I tried this:





which was not successful as welll :S


What am I doing wrong?!!