Micro:Bot

I have trouble with the micro:bot kit.

I have successfully set the kit up using these instructions (https://learn.sparkfun.com/tutorials/mi … n-makecode).

My project involves programming the micro:bot to follow a circular path. I 've followed the instruction here (https://learn.sparkfun.com/tutorials/mi … ing-a-line) and use the same code provided. Each time I set the car down, it would just spin in a circle. I tried the troubleshooting tips of checking all the wires, but it still doesn’t seem to help.

Is there anything else I can try?

Any help would be much appreciated.

Hi preh2,

When you start the robot up after uploading the code from that experiment, is the robot immediately spinning or is it only after you press the A button? When the robot is moving, what kind of behavior are you seeing from the LED matrix on the micro:bit? Finally, just to get a better look at your robot, can you please take a few photos of your micro:bot kit and attach them to your reply?

Hi TS-Mark,

After the code from “Following a Line” experiment is uploaded and the moto:bit is turned to “RUN MOTORS”, it would spin in a circle. When I press the A button, it just spins faster in a circle. When the robot I press the A button, the LED on the micro:bit would show a straight arrow. When I let the robot down to drive, the LED would show a right turn arrow.

I attached a few pictures. Let me know if you would like me to take it apart for the inside view.

Hi again preh2,

Thanks for taking those photos and explaining the issue in a bit more detail. Nothing in your hookup looks off so there’s no need to reassemble anything. The fact that the robot is moving prior to pressing the “A” button is really strange. The standard troubleshooting tip for that is to do what you have already done: Double-check your wiring and your code, your robot is not seeing the line. Also, double-check that there isn’t something like dust blocking your sensor. Even though you have already checked the wiring, it might help to just unplug and re-plug the wires for the line following sensors in. Also, what kind of surface are you testing this on? Do you have a large white surface with a clean black line with either tape or marker for the robot to follow? Lighting also affects these sensors so make sure it is in a well-lit area so the line sensors can get a good reading.

Just to clarify where the issue cropped up, if you upload the code for [Experiment One, does the robot behave as expected (eg. forward for 1 second, pivot and drive forward another second)? Similarly, if you try running the code for [Experiment Two, does the robot spin erratically as it does with Experiment Three?](https://learn.sparkfun.com/tutorials/microbot-kit-experiment-guide/experiment-2-staying-in-a-box)](https://learn.sparkfun.com/tutorials/microbot-kit-experiment-guide/experiment-1-driving-and-turning)

Hi TS-Mark,

I’ve tried checking if there is dust blocking the sensor, but there isn’t. I’ve plug and unplug the wires again. I don’t have a large white surface to test the line following so I tested it on white printing paper that I put together. For the line, I used black electrical tape. I tested it in an open area with that is well-lit.

For Experiment one:

The robot does not behave as expected when the code is uploaded. It would spin erratically. I thought it might be a motor issue so I mess with the motor codes. I set the right motor invert to “true” from “false” and the robot runs fine.

For Experiment two:

The robot runs the code but does not behave as expected. The robot would drive and continues to drive when the path is blocked. Sometimes when the path is not blocked, it would still turn.

Hmm, it sounds like the motors/driver are working properly but one or more of the line follower breakouts is not. You could test each sensor with this code:

serial.redirectToUSB()
basic.forever(function () {
    serial.writeLine("" + pins.analogReadPin(AnalogPin.P0))
})

Copy this script into the Javascript tab in a new Makecode project and then download it to your micro:bit. This will help identify which sensors are behaving properly. Once downloaded, open a serial terminal either in Arduino or using a terminal program like the ones listed in [this tutorial. Open the COM port the micro:bit is on and make sure your baud rate is set to 115200. After that, you should see values start to print and range from ~0 (more likely it will hover around 100-200) for full black to ~1000-1023 for full white. Repeat this for each sensor making sure to either adjust the pin you are reading in your code or connecting each sensor to P0 on your moto:bit. If you have any questions about how to perform this test, let me know and I can try and give you more step-by-step instructions.

If you see that all three sensors are responding to changes in light, try going back to [Experiment 3 and adjusting the value subtracted from the surface variable and see if that helps the robot behave better. If you find that one or more of the sensors are not working properly, let me know and we’ll go from there.](https://learn.sparkfun.com/tutorials/microbot-kit-experiment-guide/experiment-2-staying-in-a-box)](https://learn.sparkfun.com/tutorials/terminal-basics/all)