Posts

5 Tips for a less buggy C code

5 Tips for a less buggy C code 1. when comparing a variable to a value in if statement ,always make the value at left-hand side . Normally ,by mistake if  assignment operator (=) is  used instead of equal operator (==) in a comparison , This won’t generate any compilation error but it will generate a logical error . By placing  the value at left-hand side , if assignment operator is used by mistake instead of equal operator , a compilation error will be generated. 2. Never use pointers to decode a message containing more than one signal .This way leads to platform dependant code and reduce code reusability . for example If you have a message consisting of 2 bytes the first byte represents temperature value and the second value represents humidity value .Casting address of the message to a pointer to character to read each signal will generate different result on different endianness systems .At this case it is more safe to use shift operators to read each signal . 3. Using r

snake at 16 *32 Led Matrix

Image
Tools used at this project: 1-p10(1r)-v701c (16*32 monocolor led matrix). 2- pic18f45k22. How it works ? p10(1r)-v701c (16*32 monocolor led matrix) p10(1r)-v701c is a common anode display matrix .this picture is a simple diagram to led matrix as you can see the sixteen row are divided into four groups . each line in a group is connected to its opposite lines in other groups .for example if line (1) is on this mean that not only (1) is on but also (5,9,13) are one .rows are controlled through 3*8 encoder .columns are controlled by 16  eight bits shift register.every shift register control 8 vertical lines(vertical section) at certain horizontal group so to control all leds you need to send 16 byte through shift registers. example: let the first byte sent was 0x00 and the other bytes were 0xff .at this case the first 32 bit at the bottom of (patt1) are ready to be switched on depending on the active row .if row(4) is activated rows(8,12,16) are activa

Led_Matrix_Basics

Image
In this Project you will be able to learn Led matrix Interface using 74HC595 serial to parallel converter & 3 to 8 Decder 74HCT238 Simple Timer concept  Interrupt Service Routine  The Source Code and the Proteus Project find it  here Used Programs [Atmel Studio 6.0 & Proteus 7 professional ]