To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.nqcOpen lugnet.robotics.rcx.nqc in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / NQC / 70
69  |  71
Subject: 
Re: Does NQC support arrays?
Newsgroups: 
lugnet.robotics.rcx.nqc
Date: 
Tue, 18 May 1999 17:04:54 GMT
Viewed: 
2332 times
  
Depending on what the value in the array needs to be you could use a bitmap
(e.g. if you want to store true/false to denote the presence of
something)...  you could then represent the decimal value of the "array" of
ones and zeros ... so, for example, let's say you were looking at bricks and
want to be able to find red, green, and blue ones .... you could represent
the presence of that color as a 1 in the appropriate spot (say, in this
order: rgb) so that:

r  g b
0 0 0

so if you found a blue

001

and then a red

101

and so on... then just convert the number to decimal to ease doing math on
it and tesitng for presence of a color....

...if the # of each color was impt to you you could have a var per color

...if the sequence was impt, you'd have to find a way to store that (I'll
have to think about that)...

alternatively, you could consider zapping a message back to your PC and have
a program on that end store the info in an array for you...not sure how you
would do this in NQC but it's a piece of cake in VB .... in either case
though, you'd run into the IR tower timeout prob (turns off after 15min to
avoid battery drain - why it's not powered off of the serial port I'll never
know...maybe not enough voltage??) so you'll have to find a way to wake the
tower up periodically...

hth




Hari Wiguna <hari@mindvision.com> wrote in message
news:FBx2nH.B42@lugnet.com...
I'm building a BrickCode Reader.
Basically it reads a stack of 2x2 bricks of various colors like a barcode.
I've managed to hack together a prototype BrickCode Reader.
I can feed it a stack of bricks and it beeps different tones based on • which
color brick is passing the light sensor.
It's pretty neat actually.  I plan on using this reader to make various
things such as player piano, or a programmable robot similar to the • BarCode
Truck, etc.

Now, my problem is, I need to store these values in an array so I can use • it
to control my robot.
Of course I could have performed the actions as I'm reading the BrickCode,
but I thought it would be neater if it scans the bricks, stores the values
in an array, then repeatedly perform the actions coded in the array.

I don't think NQC supports arrays, does it?
I hope I won't have to hardcode a bunch of variables to emulate an array
(yuck!)

Another way I thought of was to use the DataLog, but I could not find a • way
to READ the data from NQC.

Any ideas?  Thanks in advance!








Message is in Reply To:
  Does NQC support arrays?
 
I'm building a BrickCode Reader. Basically it reads a stack of 2x2 bricks of various colors like a barcode. I've managed to hack together a prototype BrickCode Reader. I can feed it a stack of bricks and it beeps different tones based on which color (...) (25 years ago, 18-May-99, to lugnet.robotics.rcx.nqc)

3 Messages in This Thread:


Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR