Note. To allow motor speeds to be set individually add the More Movement extension block to the block extensions (bottom left).
The MTA- BOT instructions show how to build a simple Spike line-following robot with one or two sensors.
Build a basic one-sensor line follower
Set your motors to Ports E & F
Make sure your colour sensor is connected to Port B and is reflected light reading *
You need to use loops and if-else blocks
Can you tell which direction the robot will turn?
It wiggles a lot due to sharp turns. Adjust the motor speeds up and down to make it move more smoothly. Try using negative numbers. i.e. -10 and +10
* Please read... This needs to be done every time!
The sensors will default to colour and need to set to reflected light reading each time you open the program.
Note. If your robot goes backwards you need to reverse the motors E+F to F +E.
Add a second colour sensor
Check the reflected light reading * and use this reading in the following program.
If both sensors are > ? % then both wheels move forward @ 20%
If left sensor see <?% then start moving left @ 20% speed.
Else, start moving right @ 20% speed.
Adjust the motor speeds up and down to make it move more smoothly. Try using negative numbers. i.e. -10 and +10
What would happen if both sensors sensors black? Add another "IF" block make if both sensors < ?% then both wheels stop moving. Add a sound. Test this on your robot.
These two codes are similar. The one on the left is Step 2 (above). The one on the right uses "start moving left" or "start moving right" which may be easier for students to understand.
Using the above % on motors may allow more precise moves, especially if negative values are included. However, using turn "right" and "left" values (right diagram) can be easier for some students to follow.