Need help coding

I need help coding my marble sorter.

Do you have any current code or do you want us to code it for you?

1 Like

@EasyE , please don’t post the same question in multiple topics. It clutters up the forum.

Having one of us write your code isn’t going to teach you anything, and you haven’t given us all that much information anyway.

Try making a flowchart of exactly what you want your program to do. Make a list of the electrical components you will need. Figure out if you are using V5, Cortex, or a different robotics platform entirely. Figure out what app you are going to use to program. Try to write your program, and as you encounter specific issues, try to find solutions.


I would like some one to code it my school has been online all year and my old teacher got fired for not being helping student responding to emails and not teaching well at all. So then we got a new person that has no coding experience. She had us turn a led on from a arduino board. Then told us to make a machine that can sort three types of marbles black clear blue. She also wants you to push a button that starts it and it to stop after sorting all 15 marbles.

Thanks for the help you don’t know what it means

we can’t simply write your code for you. We have absolutely no context as far as the platform you are using, programming software, what sort of hardware and sensors you have available, ect.

like @trontech569 said, try and break down your problem into steps.

you need to figure out:

  • what kind of physical mechanism can you build that can manipulate the marbles and separate them by color?
  • how can you detect the color of the marbles so that you can make your robot move accordingly?
  • what sort of logic does your code need to follow to perform the sequence of tasks that result in a successful marble sort?

we are more than willing to give you assistance with these steps, but we’re not going to program your machine for you. And because we know nothing about your machine, we literally can’t program it for you.


Sorry about posting it twice. I am down to learn how to code this but I think that would take much more of your time. To summit up my teacher got fired over this online school year because of his lack of instructions help and his lack of effort in his job. So then we got someone new that has no history of programming. This is what the machine needs to do it needs to sort 15 marbles he needs to be started with a push button once it is sorted sorted 15 marbles it must turn off The colors that I must sort is blue black and clear. The materials like it are in Arduino board and a push button to start it three servos a LED a light sensor and I can see how much light is passing through the marble. If you can help that would be great if not thanks for the help so far.

well this is the vex forum, so while many people here probably do have experience programming with arduinos, you probably won’t find all that much specific coding help here.

to reiterate:

this is going to be the best path forward for you.

you’ve already solved the second point:

you’re going to need to figure out how to mechanically sort the marbles, one solution could be to use one of your servos to control an adjustable ramp. depending on the angle the ramp is at, it could redirect marbles to 3 different ending chambers. You would probably need to use another servo to function as a sort of valve to hold the marbles while you can test one for it’s color, and then send it to the according place. But there are many ways you can sort marbles, and you will be able to know best which one will work well for you.

the logic of the code would probably go something like this:

  • use the sensor to check the color of the marble next in line
  • move the sorting mechanism so that the marble will proceed to the correct place
  • release the marble
  • stop the next marble
  • repeat the cycle.

My idea is for a push putting to start the whole program and a light sensor reads how much light is passing through the first marble and other servos to take that information and and move to a spot and the other servo to let it go and and fall into a bucket any help would be great :+1: image here is a quick sketch of mu idea


seems like you have steps 1 and 2 figured out, the logic of the code should be fairly straightforward to figure out.

as far as the actual code itself goes, my knowledge on programming with Arduino is pretty much nothing, but I’m sure there exists tons of documentation around it.


Here is a library of servo commands, since it looks like you are using servos.


Yes that is exactly how I need it I can’t find anything on how to code do you know anyone that does. Thanks for the help

I tried to watch the videos and learn but I could not understand it that is not how I learn can you help by a chance thanks

I have very little experience coding. That was just what I got from a quick google search, there are probably more text tutorials out there. Keep looking!

:sob::sob::sob::pensive::pensive::pensive: I need help bad do you know any one that can teach me how to write this.

Take a look here:
@Drow, maybe merge this thread and the other one linked above?

Can some one help me write my code my teach is new and is no help. I will build everything. I need help bad. image Here is a picture of my idea.

Have a motor which drops a marble from the hooper one at a time. It falls to the colour sensor. When the colour sensor picks up a reading, a motor turns depending on the colour - changing where it can fall. The a motor allows the marble to continue from the colour sensor down the path and repeat.

Try just programming two different marble colours for now, it would help simplify the problem.

1 Like

There is just one problem I don’t know how to code at all do you?

I do.

Try with some of the tutorials on VEX code (you can find them in the application) and the internet. There lots of tutorials that can help you get started. But if your still not sure, try simplifying the project more. It may be too difficult if you don’t know how to program.