Shop OBEX P1 Docs P2 Docs Learn Events
Basic stamp calculator — Parallax Forums

Basic stamp calculator

afiremainafiremain Posts: 2
edited 2008-11-10 19:31 in BASIC Stamp
I am working on making a calculator that multiplies two 3 bit inputs, the most significant bits are representing polarity, and outputing this result.

I have to use the following:

variable x1, B0 is pin 0, and B1, pin 1, polarity at pin 2.· The polarity is going to be represented by a button, as the calculator operates in real time.
variable x2, B0 pin 3, and so on like variable x1.

This outputs to pins 12 through 15.·

The numbers are also represented by LED's in binary at the inputs and outputs.

I believe that this code in pbasic will work:

SIGN VAR BIT
X1·VAR NIB
X2·VAR NIB
Y·VAR NIB

(HERE I NEED TO DEFINE THE BITS IN THE ARRAYS X1 AND X2 FROM THE INPUTS)

SIGN = X1^X2, HERE I WOULD REFERENCE THE ARRAY BIT THAT REPRESENTS POLARITY

Y = ABS X1*ABS X2
IF SIGN = 0 THEN SKIP
Y = -Y
SKIP

DEBUG SDEC ? Y

HERE I NEED TO OUPUT SPECIFIC BITS OF THE ARRAY Y TO THE PROPER PINS.

I know that I can set each pin as an input or output, but how do I set a part of an array to the value of the input or output.

Would X1(0) = INPUT 0 work?
Sign In or Register to comment.