Shop OBEX P1 Docs P2 Docs Learn Events
"%" Operator Question — Parallax Forums

"%" Operator Question

D FaustD Faust Posts: 608
edited 2007-06-19 10:03 in BASIC Stamp
I would like to know what the operator of "%" does.· In the stamp manual it says that it declares a number as binary.· I have seen pin declarations given as %10011010.· What would that mean?· How does the stamp know what pins to set to those values?· I also wanted to know what they were used for in this set of code from the thread "make a Boe-Bot follow a line forward and backward."(posted below)
cutey said...

SELECT qti

CASE %000 ' Forward
GOSUB Front

CASE %010 ' Forward
GOSUB Front

CASE %011 ' Pivot right
GOSUB PRight

CASE %001 ' Rotate right
GOSUB RRight

CASE %110 ' Pivot Left
GOSUB PLeft

CASE %100 ' Rotate Left
GOSUB RLeft

CASE %111 ' Forward
GOSUB Front
.
.
.
.
Back:
PULSOUT 13, 650
PULSOUT 12, 850
RETURN

Front:
PULSOUT 13, 850
PULSOUT 12, 650
RETURN

PRight:
PULSOUT 13, 850
PULSOUT 12, 750
RETURN

RRight:
PULSOUT 13, 850
PULSOUT 12, 850
RETURN

PLeft:
PULSOUT 13, 750
PULSOUT 12, 650
RETURN

RLeft:
PULSOUT 13, 650
PULSOUT 12, 650
RETURN
Should I post my question about this code in this thread seeign on how it is related or should I ask on the other thread?· If you can tell me where in the stamp manual to find this, I will look, but I couldn't find it.· Thank you in advance· confused.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
D Faust

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-06-19 00:15
    You already have this thread so please don't post another one. Whether the value is being specified in Decimal, Hexidecimal or Binary doesn't change what the BASIC Stamps sees which is always binary anyway. All you're changing is the way you see the numbers. Binary helps when you're looking at a group of pins or states.

    Binary %101010
    Equals 42 decimal. 
    

    If you were looking at a group of pins, say INA, and you got %1010 it would indicate that P0 was LOW, P1 was HIGH, P2 was LOW and P3 was HIGH.· I hope this helps.· Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • D FaustD Faust Posts: 608
    edited 2007-06-19 01:56
    Okay, Thanks, but what is INA?· Sorry.confused.gif· I should·look at the case command in the·manual to decode that code, right?·Is the lowest number pin on the right or does 0 mean high?·· Thanks Again!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    D Faust
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-06-19 03:05
    I would recommend reading our, “What’s A Microcontroller?” manual, a free download from our website in PDF format. That and the BASIC Stamp Manual should help you understand the memory map, variables, pins, etc. Take care.

    http://www.parallax.com/dl/docs/books/edu/Wamv2_2.pdf

    http://www.parallax.com/dl/docs/prod/stamps/web-BSM-v2.2.pdf

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • D FaustD Faust Posts: 608
    edited 2007-06-19 10:03
    Thanks, I will do that.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    D Faust
Sign In or Register to comment.