vb.net barcode scanner programming VARIABLE AND PIN/PORT DEFINITIONS in Software

Generation QR in Software VARIABLE AND PIN/PORT DEFINITIONS

15.4.1 VARIABLE AND PIN/PORT DEFINITIONS
Scan QR Code In None
Using Barcode Control SDK for Software Control to generate, create, read, scan barcode image in Software applications.
QR-Code Creator In None
Using Barcode drawer for Software Control to generate, create QR Code JIS X 0510 image in Software applications.
PBASIC uses labeled variables as the methodology to store data as well as allow you to read and change the I/O pins of the microcontroller. The variables themselves can be of several different sizes; since there are only 26 bytes of RAM available for use as variables you should always strive to choose the smallest variable size that will accommodate the data you wish to store. The I/O pins can be accessed in a variety of different ways, as will be discussed in this section.
Decode QR Code 2d Barcode In None
Using Barcode scanner for Software Control to read, scan read, scan image in Software applications.
QR Code JIS X 0510 Creator In Visual C#.NET
Using Barcode encoder for .NET framework Control to generate, create QR Code image in Visual Studio .NET applications.
THE BASIC STAMP 2 MICROCONTROLLER
QR Maker In .NET Framework
Using Barcode drawer for ASP.NET Control to generate, create Denso QR Bar Code image in ASP.NET applications.
Quick Response Code Generator In .NET
Using Barcode creator for .NET framework Control to generate, create QR Code 2d barcode image in .NET framework applications.
PBASIC provides the following four variable types:
Create Denso QR Bar Code In Visual Basic .NET
Using Barcode creator for .NET framework Control to generate, create QR Code JIS X 0510 image in .NET applications.
Paint GTIN - 13 In None
Using Barcode maker for Software Control to generate, create GS1 - 13 image in Software applications.
Bit 1 bit (0 or 1) Nibble 4 bits (0 to 15) Byte 1 byte (0 to 255) Word 2 bytes (0 to 65,535)
UCC-128 Maker In None
Using Barcode drawer for Software Control to generate, create GS1 128 image in Software applications.
Code 39 Encoder In None
Using Barcode creation for Software Control to generate, create USS Code 39 image in Software applications.
Variables must be declared in a PBASIC program before they can be used. This is done using the var statement, as in
Painting ECC200 In None
Using Barcode creation for Software Control to generate, create DataMatrix image in Software applications.
ANSI/AIM Code 128 Generator In None
Using Barcode generation for Software Control to generate, create Code 128 image in Software applications.
VarName var VarType
Code 2 Of 7 Drawer In None
Using Barcode creation for Software Control to generate, create Rationalized Codabar image in Software applications.
Creating Code128 In Visual Studio .NET
Using Barcode generator for Reporting Service Control to generate, create Code128 image in Reporting Service applications.
where VarName is the name (or symbol) of the variable, and VarType is one of the variable types just listed. VarName must start with an alphabetic (a through z) or underscore (_) character and the remaining characters can be alphabetic, underscore, or numeric (0 through 9). Here are some examples:
Making Code 128B In None
Using Barcode creator for Excel Control to generate, create Code 128 Code Set C image in Excel applications.
Data Matrix ECC200 Scanner In .NET
Using Barcode recognizer for .NET Control to read, scan read, scan image in VS .NET applications.
Red var bit Blue var byte
GS1-128 Maker In C#.NET
Using Barcode printer for Visual Studio .NET Control to generate, create UCC.EAN - 128 image in Visual Studio .NET applications.
Encoding Data Matrix 2d Barcode In Visual C#
Using Barcode creator for VS .NET Control to generate, create Data Matrix image in .NET framework applications.
After reading these statements, the PBASIC compiler will make Red a bit variable and Blue a byte. It should be noted that the PBASIC compiler is pretty good at compressing variables up to eight bits in a byte, or two nibbles in a byte. In these examples and in the example code throughout the book, the capitalization of the variables is fairly carefully thought out. This is due to the authors experience with other high-level languages that do track capitalization whereas PBASIC ignores variable name and other label capitalization. The Stamp Editor will capitalize reserved words to make them stand out visually, but if you were to key in a program in a standard text editor, the capitalization specified in the text file would be unchanged and ignored by the PBASIC compiler. The following declaration statements produce the same result as the previous ones:
Creating GS1 - 12 In Java
Using Barcode generation for Java Control to generate, create GTIN - 12 image in Java applications.
Barcode Scanner In Visual C#.NET
Using Barcode recognizer for .NET framework Control to read, scan read, scan image in .NET framework applications.
Red Var Bit BLUE VAR BYTE
Single dimensional arrays can be specified by simply stating the desired number of elements for the array as part of the type definition:
Green Var Byte (10) ' 10 Bytes are used for the Array "Green"
The text after the single quote (') is known as a comment and is specifically for the use of the human reading the code. Code following the single quote is ignored by the compiler. Finally, variables can be redefined or smaller parts of variables used to extract specific data information. For example, to look at bit 2 of a returned data variable:
RetData var byte RetFlag var RetData.bit2 ' Data returned from subroutine ' Variable consisting of bit 2 of ' the returned data
15.4 UNDERSTANDING AND USING PBASIC
Once declared, variables can be used throughout a program. The most rudimentary use for variables is part of the assignment statement, which is discussed in the next section. In later sections, comparisons to different values and use in built-in functions is discussed. Variables store values that are expected to change as the program runs. PBASIC also supports constants, which are used as a convenience for the programmer. Constants are declared much as variables are, using the con statement:
MyConstant con 5
Any time MyConstant is encountered in the PBASIC program, the string MyConstant is replaced with the value 5. The BASIC Stamp treats its 16 I/O pins like additional memory that can be accessed like variables or using special functions. There are actually three different ways of accessing I/O pins, which can be confusing for new programmers, especially when the tri-state driver functions are included into the mix. Each pin has three bits associated with it. The IN bit returns the data value at the output pin. OUT is written to set the output state of the pin (if it is in output mode) and can also be read back. The DIR bit is used to specify whether the pin is in input mode (value 0 and cannot output a logic signal) or output mode (value 1 and can drive a logic signal from the pin). These three bits are generally thought of as part of three 16-bit variables. INS is the 16bit variable for each of the 16 IN bits, OUTS is the 16-bit variable for each of the 16 OUT bits, and DIRS is the 16-bit variable for each of the 16 DIR bits. The bits can be accessed as 16 bit (suffix S), 8 bit (suffix L or H), 4 bit (suffix A to D), or 1 bit (suffix 0 to 15). The suffix describes the number of bits and which ones. For example, DIRL will access the lower 8 bits of the DIRS variable. To help understand how these variables operate, look at the I/O Port Simulator at the end of the example applications in this chapter. Another way to access the I/O pins is to avoid the IN, OUT, and DIR variables all together and use the built-in pin I/O functions of PBASIC, which take a numeric value or a pin variable name (described in the following):
High # Low # Toggle # Input # Reverse # ' ' ' ' ' Put pin in Put pin in Change the Put pin in Switch pin Output Mode and Output a High Voltage ("1") Output Mode and Output a Low Voltage ("1") Output Value (Low to High, High to Low) Input Mode mode (Output to Input, Input to Output)
The problem with this method is that it does not allow for easy reading of the input pins without using the built-in variables previously specified, which can get confusing when you are new to programming. The pin declaration
Copyright © OnBarcode.com . All rights reserved.