Go to https://www.l33t.uk/bitbot/?page_id=496 for instructions on how to configure Arduino IDE for use with the BBC Micro:bit if you haven’t already. This code builds on the code found at https://www.l33t.uk/bitbot/?page_id=592
The ported code is below. It’s not a complete port I have added a clause when the robot sees 2 black lines it will go backwards. The method below was added to the ported code found here (under a new tab). Create a new tab and name it _01_LineFollower, select the new tab and paste the below code into the IDE.
I then added the following line in the void loop() method in the tab named _00_programLoop;
Now were using Arduino IDE we have freed up a lot of memory we can write a more complicated line following algorithm. The above algorithm is as simple as it gets for this stuff, in the near future I will add a much more complicated line follower algorithm.
You can download the full code from the resources section or by clicking here.