SparkFun moto:bit Board Guide

1/22/2018 micro:bot Kit Experiment Guide - learn.sparkfun.com
https://learn.sparkfun.com/tutorials/microbot-kit-experiment-guide/all#about-the-motobit-board 53/75
To compare the current reading of the line sensor to its known baseline value that was captured and stored in
the On Start block we use an if statement block. The if block accepts a logical statement. If that statement
(Sensor Value < Surface - 30) is true then the if block runs then “then” section of code. If that statement is false
then the “else” section of the block is run.
You may be asking yourself why subtract 30 from the surface value. Well, that number is a sensitivity value. The
sensor reading fluctuates as the robot moves around, by subtracting 30 from the original surface variable we give the
change in lighting a “wiggle room” of 30. If you want your sensor to be more sensitive you make the number smaller, if
you need it less sensitive make it bigger.
What You Should See
Once your code is loaded find a light surface, preferably white and add a line of black tape to the surface and press
the RESET button on your micro:bit. In fact, if you have a large enough space you can create a 3' square you will be
perfect! Change the motor switch from “STOP MOTORS” to “RUN MOTORS.”