3.2 Your First mikroC Pro for PIC Program

Figure 3.1 shows a very simple mikroC Pro for PIC program. This program turns ON all the 8 LEDs connected to port B of a PIC microcontroller. Then, after a 500 millisecond delay, all the 8 LEDs are turned OFF. Do not worry if you do not understand the operation of this program at this stage, as all will be clear as we progress through this chapter. Some of the elements used in Figure 3.1 are described in detail here.

Figure 3.1 A very simple mikroC Pro for PIC program



Comments are used in programs to clarify the operation of the program. Although the use of comments are optional, it is strongly recommended that you use as many comments as possible in your programs, as comments make your programs readable and easily maintainable. Imagine how hard it would be to write a complex program with no comments and then try to modify the program after several months. All the comment lines are ignored by the compiler.

In mikroC Pro for PIC language, comments can be of two types: long comments and short comments. Long comments start with the character pair:


and end with the character pair:


Long comments are commonly used at the beginning ...

Get Using LEDs, LCDs and GLCDs in Microcontroller Projects now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.