Basic analog and digital. Student guide, version 1.2 by Andy Lindsay

By Andy Lindsay

Show description

Read Online or Download Basic analog and digital. Student guide, version 1.2 PDF

Best technique books

Extra info for Basic analog and digital. Student guide, version 1.2

Sample text

Since the input values were set to the variables, a and b, we can use a and b to dictate the output values at pins P4 and P5. OUT4 = b OUT5 = a We could just as easily have used the commands OUT4=IN1 and OUT5=IN0; however, using variables to store the values in memory has advantages as the programs get more complicated. In the next experiment, it will be necessary to use variables to store values. The reason we used variables in this program is because they can be manipulated arithmetically, and the next task is to convert from binary to decimal.

Make sure the Board of Education has power and the programming cable is properly connected, then run the program. 1 Revision 0. 5} a b d VAR VAR VAR Bit Bit Nib INPUT 0 INPUT 1 OUTPUT 4 OUTPUT 5 DEBUG CLS DO a = IN0 b = IN1 OUT4 = b OUT5 = a d = (2*b) + (1*a) DEBUG HOME, "State of pin P0 is ", BIN a, CR DEBUG "State of pin P1 is ", BIN B, CR, CR DEBUG "2-bit binary number: ", CR DEBUG "P1 P0", CR DEBUG " ", BIN b, " ", BIN a, CR, CR DEBUG "Decimal equivalent: ", DEC1 d, CR LOOP The Output Here's how the program should work.

The numbers were chosen based on BASIC Stamp I/O pin numbers. ' -----[ Initialization ]------------------------------------CS PIN 0 CLK PIN 1 DataOutput PIN 2 Next there's the main routine section containing three GOSUB commands. The DO…LOOP loop runs 3 different subroutines over and over again. The subroutines are named ADC_Data, Calc_Volts, and Display. Subroutine is a small program that does a specific task within a larger program. ' -----[ Main Routine ]--------------------------------------DO GOSUB ADC_Data GOSUB Calc_Volts GOSUB Display LOOP So, how does a GOSUB command work?

Download PDF sample

Rated 4.61 of 5 – based on 28 votes