I have a new project with codey rocky. (By next Tuesday)


I have a new project with codey rocky. (autonomous car or self driving car)

I have a question.

(1)I made line following and identify colors (red or green), But I can’t combine the two codes. If I combine the two codes, there will be an error. Please fix it and Please let me know if there is a way.

Please send me What I need to build autonomous car (or self driving car) and the code!

[Please refer to the attached video.]


Hello junwoo0317,

I’m having a bit of trouble keeping up because the video shows mBots with color sensors on top.

For the Codey Rocky the color sensor will probably be on the floor? It’s practically the same code.

Questions :

  • Is that a Codey Rocky?
  • Will the colors be on the floor? If so, the Codey will not be able to stop at the barrier because its sensor will be directed towards the ground.


Thank you for your response.
Yes, It’s Codey rocky. Okay,
Then, how do I combine two codes? ( line following, Wall Recognition)
Also, can I fix the problem by buying neuron? (It’s about ‘Will the colors be on the floor? If so, the Codey will not be able to stop at the barrier because its sensor will be directed towards the ground.’)


Hi junwoo0317,

Here is a solution with Neurons. Just attach an UltraSonic Sensor and you can follow the lines, stop by color and avoid obstacles. However, there is a cost for simplicity (I am purchasing more material)



Otherwise, you don’t buy anything more and replace your barrier using a servo motor with a floor barrier.

  1. Select a color (Example: Green)
  2. Place your servo motor so that it rotates and slide it across the road on the ground.
  • Otherwise you push the slide in parallel.
  • Otherwise you can freak him out.

If you want to change your barrier, I have a few ideas in mind … just let me know.


What`s the code? (Wall Recognition neuron)
And if I combine the two codes, I get an error.


Maybe this ??


Thanks for sharing @Crackel :grinning:


Hi kgingeri,

If it’s for students, you can make it easier.

A black line in the center, a red line on the left and a green line on the right. If the Codey sees green, it turns left. If he sees red, he turns right and if he sees black, he goes forward.


Hi junwoo0317,

When I bought the Codey Rocky, I felt like programming would be easier. However, I haven’t found the way to track lines like mBot. I would like someone to explain to me how to do without Neuron to follow a line, read colors and stop at a barrier. Come to think of it, I don’t believe the Codey Rocky is made to do all of this?

Here is an alternative


Please combine with line following code.
I attach the line following code.


I would like to help you but I need the two programs that you want to combine and the failed attempt.

Please do not provide french screenshots, I understand only german and english. Make your programs downloadable, for example via DropBox, if you do not have access to a web server.




This is a file link.


Thank you. This is the very simple line follower which you showed already above. I can open the file and see the labels in german, which is helpful to me.

But where is your second program that you want to combine and where is your failed attempt of the combination?


The second file is this.
But this is how the bug happened.
Only one will be executed.


Please take a look at this image. The trick is to use a status variable which tells if the robot is doing a pause or if he is moving. Only if not in pause status, then we sense the line and control the motors.

Red (and button B) switches the pause status on, green (and button A) switches the pause status off.

However the color sensor does not work well on my device. It does randomly detect all possible colors, so the robot starts and stops moving unexpectedly. I hope your sensor performs better.

Your line follower controls the motors digitally. The robots makes a zig-zag movement because your code tells it so steer either to the left or to the right digitally. Two weeks ago Crackel posted a better line follower solution which controls the motors depending on brightness. This way you get an analog steering which is much smoother.


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.