ME Labs, Inc. 719-520-5323 |
ME Labs, Inc. | 1-719-520-5323 | Example Program - CASE.pbpPICBASIC PRO program to demonstate the Select Case...Case... End Select structure. Each loop results in the same output using slightly different conditions.' Name : CASE.pbp ' Compiler : PICBASIC PRO Compiler 2.6 ' Assembler : PM or MPASM ' Target PIC : 16F or 18F types ' Hardware : Non specific ' Oscillator : internal or external ' Keywords : DEBUG, CLEAR, SELECT CASE ' Description : PICBASIC PRO program to demonstate the Select Case...Case... ' End Select structure. Each loop results in the same output using slightly ' different conditions. ' ' Define Debug pin Define DEBUG_REG PORTC Define DEBUG_BIT 6 Define DEBUG_BAUD 9600 Define DEBUG_MODE 1 B10 VAR BYTE ' Used to count and to specify the case loop1: ' First example Pause 250 B10 = B10 + 1 ' Increment B10 Select Case B10 ' Begin Select Case - use B10 Case 1 ' Execute if B10=1 Debug "loop1 case 1",10,13 ' Send string and new line Case 2 ' Execute if B10=2 Debug "loop1 case 2",10,13 Case 4 ' Execute if B10=4 Debug "loop1 case 4",10,13 Case is >5 ' Execute if B10 > 5 Clear ' Set B10 to 0 Debug 10,13 ' Send new line GoTo loop2 ' Finished - jump to second example Case is >2 ' Execute if B10>2 (but not >5 or =4) Debug "loop1 case 3,5",10,13 End Select ' Resume here after case is executed GoTo loop1 ' Continue first example loop2: Pause 250 ' Second Example B10 = B10 + 1 ' Increment B10 Select Case B10 ' Begin Select Case - use B10 Case 1 ' Execute if B10=1 Debug "loop2 case 1",10,13 Case 2 ' Execute if B10=2 Debug "loop2 case 2",10,13 Case 4 ' Execute if B10=4 Debug "loop2 case 4",10,13 Case is <6 ' Execute if B10<6 (but not = 1,2, or 4) Debug "loop2 case 3,5",10,13 Case Else ' Execute if no other conditions met (B10>5) Clear ' Set B10 to 0 Debug 10,13 ' Send new line GoTo loop1 ' Finished - jump back to first example End Select ' Resume here after case is executed GoTo loop2 ' Continue second example End Download the program file. |
Copyright 2019 ME Labs, Inc. PO Box 8250 Asheville NC 28814 (719) 520-5323 (719) 520-1867 fax email: support@melabs.com |
|