i have an robotic project , where i must solve an rubics cube by getting the soultion squens form an pc application throw the serial port. Every think is okey , but the solving programm send the soultion squens as a string to arduino in this form soultion = "R L2 R' F D2 B L;" , where every cahrecter means a movment. i would like to split this stirng by a space , that between the charecters. I tried my some c++ knowleg but some where i dont get what i want.
ex. the input = "R L2 R' F D2 B L" .........etc
expected output =
and then if it possible to do , i would like to save this output into string array.
Split Serial input by a specific charecter like a Space,*not necessary* and save it into array
Actually the low-level strtok() does that well, see this example
Then depending on how you want to process the results loop through them.
But for a higher level approach you can use my SafeString library or Strings indexOf and substring
I have a couple of questions if that is okay.
Have you established a connection between the Arduino and the computer? And if so is the conversion of your string something you want to convert on the computer or the Arduino?
Are you able to get the string to the Arduino as a variable?
Do you have any code and/or data you can publish to help me get af better understanding of your problem and how fare you are in solving it?
This post covers the same ground
and contains (in amount the arguments) at least two solutions.
thank you , i think i will use strock() , what ever i search i found it . thank you again for the help
Hi, Yes there is no problem in connection between the arduino and the pc.
the code is undr this Link on GitHub
its not ready for all functions yet , but it will be in some few days after system integration test.
example soultion "R L2 D2 R F B L D R' L' F2 U R L' F2"
the letters means F : Move the Front face of the cube in clockwise direciton
R : Move the Right face of the cube in clockwise direciton
B : Move the Back face of the cube in clockwise direciton
L : Move the Left face of the cube in clockwise direciton
U : Move the Upper face of the cube in clockwise direciton
D : Move the Bottom face of the cube in clockwise direciton
2 : move in the same direction 2 times
' : move the face anti-clockwise direction
thanks for your time.
i forget some thing , i dont have the source codde of the pc programm , because its from an another team of this project
yes, thank you for the correction
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.