Tic Tac Toe Robot Programming......?



This is my new robot I built. I built it thinking i would program it so you could play against the robot or against another human. But now that i am finished i have no clue how to program it at all. to play you would push the button on the x-axis corresponding to your placement and then the one on the y axis then you would hit the ok button and the robot would place the piece where you wanted it. then depending on what you typed in the robot would place its piece and you would play tic tac toe. to play against a friend you would move the potientometer and it would switch modes and you and your friend would type in the cordinates to play against each other. let me know if you can help.


Sup Tuel,

Very interesting robot.

I can see that you have an encoder on each axis. If we label the buttons from left to right, and from top to bottom, like a coordinate plane, you have buttons, x1, x2, x3, y1, y2, y3.

What you can do is set each button equal to an encoder value. So when someone hits button x1, the encoder need to go to value 50(you’ll need to test your program to figure out these values). Since you can an encoder on each axis, you’ll do the same thing for all of them. Where x1, x2, and x3 only move the xaxis encoder, where y1, y2, and y3 only change the y-axis encoders.

As far as programming a release is concerned, that’s relatively simple. You just program your button to release the pieces. I can’t see your release “mechanism”, but it’s a button program.

And when you want to play the computer, I have no idea how to program the logic behind that. I’m sure you can find a great sample code online for tic-tac-toe logic.

Also, What programming language are you using?

I am using easy c 2.0. I have a servo that pushes each game piece out.

You can program a button so that when you push it, the servo move forward and knocks it out.

how do you just make a motor turn untill the encoder reaches lets say 50?

awesome set up you have!
this is how i use the encoders and it seems to work on easy C.

start the encoder
make a while loop
return the encoder count to a variable (get function),
make two if statements saying if variable is less than 50, and another for if the variable is greater than or equal to 50.
In the less than 50 statement set motor running, in the other set motor stop.

That is how i would do it but i’m sure there are many other ways which other people could suggest :slight_smile:

It would be better to make a Proportional Control Loop.

MotorOutput = Gain * ( Target - Input );
SetPWM ( 1 , MotorOutput + 127 );

So, if you want to move the axis to say 120 encoder clicks you just set the target to 120. Start with a Gain of 1 and increase it or decrease it based on speed. If it runs away from the goal invert the encoder direction.

You could store the X, Y Locations in an array. See the help file on arrays to see how to program it.

:eek:This Robot looks rely rely cool!:D! How long did it take you to build it??:confused: