Page 199 - The Ultimate Palm Robot
P. 199

Color profile: Generic CMYK printer profile
           Composite  Default screen
                                                      Bots / The Ultimate Palm Robot/ Mukhar & Johnson / 222880-6 / Chapter 7






                    182     The Ultimate Palm Robot



                                 As a general rule, you will want to open the serial port to the SV203 control-
                               ler when your program starts up, and close the port when the program ends.
                               To do this, right-click on the Project1 element in the Project Explorer window.


































                                 Select View Startup Code, and enter this code:


                               Sub Project_Startup()
                                   SerialOpen(0, 9600)
                               End Sub

                                 This code will, as you might guess, open the serial port for you. Note that
                               NS Basic automatically enters the Sub and End Sub lines of code, and all you
                               need to enter is the SerialOpen( ) function call.

                                 Now right-click the Project element again and select View Termination
                               Code. Enter this code in the window:


                               Sub Project_Termination()
                                   SerialClose()
                               End Sub








           P:\010Comp\Bots\880-6\ch07.vp
           Monday, May 12, 2003 4:29:26 PM
   194   195   196   197   198   199   200   201   202   203   204