Gear construction and Ultrasonic for the FIRST LEGO League Senior Solutions Medicine Pro Preview

In this episode I would like to show you a way to solve the FLL 2012 Medicine mission using an LEGO Mindstorms NXT Ultrasonic Sensor and a system of gears that converts circular motion to linear.

  • #16
  • 12 Apr 2013
  • 9:33

There are a number of ways to solve the FLL 2012 Senior Solutions Medicine mission. Here I would like to show you an interesting way to do that using an LEGO Mindstorms NXT Ultrasonic sensor and a gear system. Teams are using light or color sensors most of the time during the competitions most of the time teams were using light or color sensors and the Ultrasonic sensor is neglected.

The gear system that we are using transofrms circular motion to linear motion. It is an interesting attachment that you could learn much from. Feel free to use it in this or similar way in your robot.

Share with us some pictures and stories of how you are using it. It would be valuable for us :)

Mentioned Episodes:

Take a look at Episode 10 for building the menu block used in this video.

Building Instructions:

  • You could find the instructions for building the robot in Episode 13

Gear attachment

Building instructions for the gear attachment. 

Gear attachment

- download building instructions for the gear attachment. Note that you will need both LEGO Digital Designer and LDView to open the instructions. There are limitations in the LDD software and for the .ldr file in the archive you should use LDView installed along with LDraw


- download the whole program for solving the medicine mission from the 2012 FLL competition Senior Solutions.


In this episode I would like to show you a way to solve the FLL 2012 (Senior Solutions) Medicine mission. We will use our eyes, the menu myBlock we have created in episode 10 and the Ultrasonic sensor to locate the green medicine. Afterwards using an attachment with a gear system that converts the circular motion to linear and a lock, we will take  the medicine.

I have changed the gear system connected to the third motor in order to make it convenient to connect attachments. I will talk about this in one of the next episodes. Now I want to add ultrasonic sensor to the base construction. The first thing is that I will attach it vertically instead of horizontally, because when it is horizontal the distance between the two eyes is almost as the distance between the two ends of the medicine and it will be hard for the robot to detect the medicine. I will attach it using these parts, here. So I will connect it with the ultrasonic sensor like this. Then I will connect the cable and connect the sensor to port 4. Finally, I connect it to the base, like this. It is ready to use.

Now, when we have the ultrasonic sensor connected, I want to check what is the distance between the robot and the medicines. I will do that using the View menu on the NXT brick, use the ultrasonic sensor on port 4. The distance till the wall is 14 cm and the distance to the medicine is 8 cm.

Make video with the program

Now I want to build a program that will make the robot stop on the medicine we have chosen from the brick. I will do that using the myBlock we have created earlier. I will set the minValue to 1 and the maxValue to 4 and the y coordinate to 32, because that is the middle of the screen. Then I will define a new variable, called Result, and it will be Number type. So I will store the selected value from the menu into the Result variable. Then I will take a Loop block and make the robot go unlimited until it sees an object less than 10 cm away. When it sees an object less than 10 cm away, that means that it has reached a medicine. So I will decrease the value of the Result variable. That is by using Math block and after the value of the Result variable is decreased, I will compare it with 0. If the variable is equal to 0, that means that we should stop to look for medicine, because we have reached the one we want. So I just have to add a Stop block at the end of the program. Now let’s download the program and see how it works.

Let’s choose the second medicine and press the Orange button. The robot stopped on the first medicine, so the program does not work.

Okay, so the problem is that the robot sees several times the medicine. In order to overcome this problem, I will use a Wait block, which I will set to 0.2 seconds and it will give time for the robot to move on the next medicine. Now let’s download the program.

Okay, so now let’s see how the program works. I will again choose the second medicine. This time, as you can see, the program works perfectly.

Okay, so now we need an attachment, that will take the medicine. I have built this one and you can find building instructions for it under this video. Now I will stop only on the important parts of it. The first one is the lock, here. The medicine can get it, but could not get out. This is achieved by letting these parts move freely and put this part in front of them in order to stop them moving in this direction. Next, it is the system of gears, which transforms the circular motion from the motor to linear and makes the attachment move back and forth. Finally, the attachment is connected with the robot easily and it’s ready to use.

Now let’s see how many degrees motor A should do in order to get the attachment out. I will do this again using the View menu, go to motor degrees and choose port A. I will rotate manually and it’s 377 degrees.

Now  I will take a Move block and set motors B and C move backwards for 1.3 rotations in order to align the attachment to the medicine. Next, we need motor A to move backward 1 rotation exactly or 360 degrees and then move forward, so that it returns the medicine. Finally, we need Move block making motors B and C move backwards, let’s say 10 rotations. We need to be sure that the robot get back to base and finally let’s download the program.

Okay, so now let’s try to take the third medicine. As you can see, it barely catched it, so I will change the getting back Move block to be 1.1 rotations.

So now we will change it from 1.3 rotations to 1.1 rotations and download the program.

So now let’s try again to take the third medicine... and, as you can see, the program is working perfectly.

Lessons with this tutorial

This tutorial is used in the following lessons

  1. FIRST LEGO League Competition. Attachments / FIRST LEGO League 2012 Senior Solutions. Example soluations

    1. ***Tutorial****

    2. Gear construction and Ultrasonic for the FIRST LEGO League Senior Solutions Medicine
    3. ***Tutorial****

    4. ***Tutorial****

    5. ***Tutorial****

    6. ***Tutorial****

    7. ***Tutorial****

    8. ***Tutorial****

    9. ***Tutorial****

    10. ***Tutorial****

    11. ***Tutorial****