ROBOTC.net forums
http://www.robotc.net/forums/

prioritizing and remembering
http://www.robotc.net/forums/viewtopic.php?f=11&t=5676
Page 1 of 1

Author:  tylertnooo [ Sat Apr 06, 2013 6:37 pm ]
Post subject:  prioritizing and remembering

For Vex Cortex

Is there any way to prioritize and remember button being pushed?

Example:
I was in an elevator and I push button 1, somebody else steps in an pushes button 2. Another person steps in and pushes button 3.

button 1= floor 1, button 2= floor 2, etc. . .


Is there any way that I could have the cortex remember the order those buttons are pushed and perform the functions associated with those buttons?

Also is there a way that I could have the cortex preform the tasks so that they are operating in the most efficient way possible.

Example:

The elevator was on floor 4 so it will go to floor 3, then 2, then 1.

Author:  Eddie [ Sat Apr 06, 2013 8:23 pm ]
Post subject:  Re: prioritizing and remembering

tylertnooo wrote:
For Vex Cortex

Is there any way to prioritize and remember button being pushed?

Example:
I was in an elevator and I push button 1, somebody else steps in an pushes button 2. Another person steps in and pushes button 3.

button 1= floor 1, button 2= floor 2, etc. . .


Is there any way that I could have the cortex remember the order those buttons are pushed and perform the functions associated with those buttons?

Also is there a way that I could have the cortex preform the tasks so that they are operating in the most efficient way possible.

Example:

The elevator was on floor 4 so it will go to floor 3, then 2, then 1.


For the first issue, you can use an array and store the buttons as they are pressed. Here is a good website for learning about arrays: http://robodesigners.blogspot.com/2012/04/arrays-in-robotc.html

For the second issue, you can sort the array right before you proceed to a floor. There are a lot of programming techniques for sorting, the easiest of which would be http://en.wikipedia.org/wiki/Selection_sort. It is not the most efficient way of handling it but it would work. It would be problematic if you are above the lowest floor set, though, as it would travel all the way to the bottom before proceeding back up. I would handle this by putting the current level in an array with all of the values higher than it (sorted from the lowest, which should be the current floor, up to the highest) and creating another array with all of the lower values (sorted from the lowest floor up to the closest floor to the current one). This may not be the most efficient way to solve the problem, though.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/