Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

How to create a Bitmap For a Dinosaur using PIC16F877A

dexter419

New Member
How can I create a bitmap for a dinosaur using a PIC16F877A micro controller? I am seeking detailed guidance on the steps involved, including the programming aspects and any hardware considerations, to effectively generate and display a bitmap of a dinosaur on a display connected to the PIC16F877A.
 
Assuming there is not enough memory to store such a bit map in the memory of the PIC16F877A part, I would build an interface to an SD Card which would store the bit map. The PIC16F877A would then serve as a pixel pump to serve up the output to the display.
 
this is for a project, where i would be implementing the Google dino game, normally i could use a an ASCII code to represent the dinosaur and the tree obstacle, but i will like to make the game more realistic
 
IIRC the PIC16F877A has 8K x 14 bit words of flash program memory. Depending on the field size and the number of pixels involved, you might be able to fit a single static image in a portion of that, but I would expect that to be a tight fit.
 
You can compress the image fairly simply by using "run length" -
eg. one byte, high bit normally clear, that gives you seven bits for up to 127 pixels of that colour sequentially within a line.

Start each row with white, even if there is none, so the count is zero.
The last byte in a row would have the high bit set to mark the end.

Each full pixel row would take two to at most five bytes, like that.
(Or just one if the entire row was white & no more than 127 pixels).

If you need more than 127 pixels the same, use a dummy zero count of the opposite colour then the rest of the row in the next byte, like 127[W], 0[ B ], 127[W with the high bit set], so 254 max white pixels with three bytes.
 
How can I create a bitmap for a dinosaur using a PIC16F877A micro controller? I am seeking detailed guidance on the steps involved, including the programming aspects and any hardware considerations, to effectively generate and display a bitmap of a dinosaur on a display connected to the PIC16F877A.
I would suggest moving from the antique 16F877 to something much more modern (and probably cheaper), which will have much more memory (so more chance of storing a bitmap), and run much faster as well. You've also more chance of interfacing an SD Card on a modern device the 16F877 doesn't have enough ram to do it properly.

My current 18F favourite is the 18F27K42, which has lot's of program memory, decent amounts of ram, and runs at 64MHz.

For more 'oomph' you could look at the 32 bit PIC's?.
 
For large memory and general high speed, my favourites are the DSPIC33E series.
16 bit, 120MHz clock. I use bitmap images with those, converted to data arrays to add in the program files, then parsed and displayed as needed.

Example - 256K Flash and 32k RAM; plenty of space for large image files:

The next one up from that, DSPIC33EP512GP502-E/SP, has 512K flash and 48K RAM, but slightly more expensive.
 
As Nigel has already said.. using a pic16 is doable, but it will be a struggle.
I use a pic18f46k22.. Tons more memory and peripherals.. Are you going to use a graphic screen? Or use the 8 characters of an alphanumeric screen? the latter will work with the pic16. I might give this a go
 
I don't see anywhere where you mention the GLCD (?) you are using. Is it bit addressable? If not, that needs to be done in code, e.g., entering b'0000 0001' in page 0, or the reverse, may add a bit. But is that what you mean by addressing bits? Or, can you easily address individual bits?

Here an example of a little project I did awhile back with a PIC 16F1xxx. It's a roast thermometer that predicts when the roast will be done given a target temperature. Ignore the labels on the keys. I used a box from something else and hadn't changed the labels yet.
1701987647474.png


Each increment on the X-axis is 8 bytes. So, 60 increments (1 hour at one increment/minute) is just 480 bytes. Since it is a histogram, i.e., one byte of data for each increment, I squeezed the entire graphic into 64 bytes. Instead of implying you need to address and store 64 x 128 individual bits(?), we need more specifics about what you are trying to do. BTW, that display scrolls up and down, but only to the left. There is no way to predict the future with a simple PIC.
 
You might have to choose a running stickman.
 
You might consider the Nextion display.
It also comes in touch screen.
It will store a few nice resolution bitmap pictures onboard.
Maybe even animation of parts of the pictures, if you are tricky.
 
this is for a project, where i would be implementing the Google dino game, normally i could use a an ASCII code to represent the dinosaur and the tree obstacle, but i will like to make the game more realistic
What resolution display do you need? How many bitmap images are needed? Are the bitmap images stored in full or altered with code?
 
No one can do anything much useful until the thread starter says what display they are hoping to use!

They keep re-visiting the forum but not posting anything....
 
How can I create a bitmap for a dinosaur using a PIC16F877A micro controller? I am seeking detailed guidance on the steps involved, including the programming aspects and any hardware considerations, to effectively generate and display a bitmap of a dinosaur on a display connected to the PIC16F877A.
The dinosaur appears to be no more than 32 pixels wide x 32 pixels tall, so it can be stored as an array of 32 32-bit integers, 64 16-bit integers, 128 8-bit bytes, etc.

The implementation depends on the display being used as well as the programming language you're using.
 
i am trying to implement the Chrome Dino Game on the PIC16F877a micro controller, for any one who doesn't know the game
. currently i have this code, which is meant to have ascii characters to constantly shift left on the lcd display, i have encountered an issue using the shift left function, as now, it also shifts the dinosaur character to the left, what can i do to change this .
Code:
    level = 2;
    position = 4;
    
    Lcd8_Set_Cursor(level,position);           //dinosaur character
     Lcd8_Write_Char(105);
    

    Lcd8_Set_Cursor(2,7);                           // obstacle one
    Lcd8_Write_Char(219);
    for (int i=0; i < 5 ; i++){
         __delay_ms(1000);
        Lcd8_Shift_Left();
    }
    
     Lcd8_Set_Cursor(2,12);                       //obstacle two
    Lcd8_Write_Char(219);
    for (int i=0; i < 5 ; i++){
         __delay_ms(1000);
        Lcd8_Shift_Left();
    }
 

Latest threads

New Articles From Microcontroller Tips

Back
Top