View unanswered posts | View active topics It is currently Fri Oct 31, 2014 7:47 pm






Reply to topic  [ 4 posts ] 
Problem Cell 
Author Message
Rookie

Joined: Tue Mar 11, 2014 3:04 pm
Posts: 2
Post Problem Cell
Good evening
I do a lot of research and I have a problem, I have a 21 * 30 table consisting of 1 and 0, looking for a way to read cell by cell that starts with the beginning (top left).
Thereafter have this possibility: If 'cell' is equal to 1 => instruction.
Thank you


Last edited by Skio on Mon Mar 31, 2014 4:55 pm, edited 3 times in total.



Mon Mar 31, 2014 2:21 pm
Profile
Moderator
Moderator

Joined: Thu Jan 03, 2013 5:10 pm
Posts: 198
Location: The plateau north of the Ohio River Valley, also known as Cave Country.
Post Re: Problem Cell
You are in need of an array. Arrays are chunks of data that can be accessed by an index. To declare an array, do this:

Code:

<type> <variable name>[<length>];

// Example

int myarray[3];



Initialization of arrays with starting values is as follows:

Code:

int myarray[3] = {1, 4, 27};



Also, ROBOTC supports 2D arrays on some platforms, and the NXT is one of them. This is a 2D array:

Code:

int my2darray[4][3];

// With starting values

int my2darray[4][3] =
{
    { 1, 2, 3},
    { 9, 4, 1},
    { 6,90,37},
    { 2, 0,81}
}



To access a value in an array, use the index values for that data. Note that arrays are zero-based, meaning the first value is [0], not [1].

_________________
I'm not a robot! I'm british! ~ quote from an asparagus
I am not a robot! I am a unicorn! ~ quote from a robot


Mon Mar 31, 2014 4:14 pm
Profile
Rookie

Joined: Tue Mar 11, 2014 3:04 pm
Posts: 2
Post Re: Problem Cell
I'm sorry I'm a beginner, I think I explained my problem wrong,
I have an external file '.mat 'is a array containing only 1 and 0, I would scan each cell starting with (1,1) and (2,1) then '(3,1) [...] (21,31). If the cell is equal to 1 my robot made ​​a instuction, if the cell is equal to 0 the robot nothing.


Attachments:
monochrome.png
monochrome.png [ 30.36 KiB | Viewed 601 times ]
Mon Mar 31, 2014 4:51 pm
Profile
Moderator
Moderator

Joined: Thu Jan 03, 2013 5:10 pm
Posts: 198
Location: The plateau north of the Ohio River Valley, also known as Cave Country.
Post Re: Problem Cell
Oh, ok. Since the file is stored on your computer, you will need to do this:

Using a computer language ( I recommend C#), create a program for your PC that reads the file and then sends it to your nxt via a serial port with a bluetooth dongle. You will have to know how to read the .mat format, which you can figure out by looking it up or by contacting the developer of your matrix editor. Have an nxt program that reads the incoming messages and uses them.

Of course, there are downsides to this: You will likely have to learn a new language, purchase a dongle (although I think somehow you could use the USB cable as well), and spend much time. Thus, you may want to consider manually hard coding in the matrix straight to your robot. That, too, can be time consuming.

A third and final option which would probably be best (I saved the best for last :) ) would be to find a program on the web already written to do what I described in the first option with a USB cable. The only problem with that is seeing if such a program exists.

-A

_________________
I'm not a robot! I'm british! ~ quote from an asparagus
I am not a robot! I am a unicorn! ~ quote from a robot


Wed Apr 02, 2014 3:03 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.