Sumo mBot

Get your mBot ready for battle in the ancient Japanese art of sumo wrestling. Program your robot to search for your opponent (with the ultrasonic sensor), and when found, attack.

NOTE: This lesson is intended for use with 2 mBots fighting on a table. Please note that the mBots may fall off the table. Appropriate measures must be taken to ensure that no damage is caused while engaging in this activity.

Remember the values that are returned by the line follower sensor:

table

So there are 2 different sensors which affect the behavior of the mBot. This can be displayed in the following table:

table-of-actions

Now we have the actions clearly defined, we can write some pseudocode for our program:


Forever {
---- While (the robot has not detected an edge) {
---- ---- If (an enemy is detected)
---- ---- ---- Charge
---- ---- Else
---- ---- ---- Move forward
---- }
---- Turn
}

Transferring this into code looks like this:

sumo-code

Challenge:

  1. Use the LEDs and the buzzer to signal the different actions.
  2. Have a competition. Can you change the code to make the mBot do better in the competition?

Construct Your Dreams!