mBot 2 line following code with Python


#1

Hey guys, I’m new to the forum and pretty new to programming with python and mbot2, so HI ALL! :slight_smile:

I’m currently trying to get my mbot to drive on a road.
The borders of the road are black, the road itself is white, so I’m trying to work with the quad RGB sensors.

The code I’m currently using is very limited. It goes something like this: if sensor 4 sees white, the mbot mikes a slight turn to the left. As soon as the sensor starts to see the black line, it moves to the right again…

Do you have any other ideas, on how to get my mbot to follow a road (as quickly as possible)?

Thanks guys!
Cheers
Nudelauflauf


#2

Does this code work?

https://drive.internxt.com/sh/file/8d05028e-bd38-462f-a62d-ea25cb70a30a/9de6d3188dbfe5f7f74eb88831d362e99728fa4045a0b26ec538db8d8ea938a6

@Nudelauflauf Let me know!