Page 44 -
P. 44

CodeDesigner 31

                          With the CodeDesigner options set, we are ready to write our first program.

            First Program

                        Start CodeDesigner and enter the following code for the PicBasic compiler.
                          ‘First PicBasic program to wink two LEDs connected to port b.
                           loop: high 0            ‘Turn on LED connected to pin rb0
                              low 1                ‘Turn off LED connected to pin rb1
                              pause 500            ‘Delay for .5 second
                              low 0                ‘Turn off LED connected to pin rb0
                              high 1               ‘Turn on LED connected to pin rb1
                              pause 500            ‘Delay for .5 second
                              goto loop            ‘Go back to loop and blink & wink LEDs forever
                              end

                          The next program is identical in function (not code) to the PicBasic program
                        above. Start CodeDesigner and enter the following code (see Fig. 4.11):

                          ‘Wink program
                          ‘Blinks and winks two LEDs connected to port b





































                        Figure 4.11  PicBasic Pro program written in CodeDesigner.
   39   40   41   42   43   44   45   46   47   48   49