Open the arm when te object is close (using the IR distance sensor)
In this lecture you will not move the robot forward or backwards, but use one of the sensors of the Ozeki Dozer. Namely the IR distance sensor (on the front of the robot), which you can use to measure distance. The program will control the robot in a way that it will open it's gripper if some object is near enough to the infrared distance sensor and grabs the object by closing the gripper.
Figure 1 - Closes the claw of the Dozer on the object
Terms and Definitions
- Gripper: The claw of the Ozeki Dozer. It consists of two arms which can be open or close.
- IR sensor: The infrared sensor can detect signals from an infrared beacon and also can measure the distance of the nearest detected object. It has got three different modes for the users: proximity, beacon and remote. In this case, the proximity mode was used.
- Proximity: Nearness in space, time or relationship. In this case, we mean the nearness in space on proximity.
Requirements
- Ozeki 10 installed: http://www.ozeki.hu/index.php?owpn=6066
- Ozeki Dozer: http://www.ozeki.hu/index.php?owpn=6203
- Lego connection installed: http://www.ozeki.hu/index.php?owpn=6067
- SNAP basics: http://www.ozeki.hu/index.php?owpn=6180
Program code
Figure 2 - Program code that measures distance with IR sensor
![]() |
Download the program The program is capable to open the gripper when something is near to the robot. It is easier to do the steps if you have the program in front of you: Download the program code |
Step-by-step guide
After you have connected the Dozer to Ozeki 10, you can start programming. Open SNAP in Ozeki 10 and put a 'when green flag clicked' block down. The next block is 'forever' (see Figure 3). It is an infinite loop which means it will not stop executing the encapsulated blocks again and again, only if you click on the stop button near to the green flag button. Inside the 'forever' block put a 'wait until X' block where X is a condition. The execution will be paused until the condition becomes true.
Figure 3 - The first part of the program
Put an 'X < X' block into the 'wait until X' block's condition part. Set an 'Object proximity [sensor]' block ([sensor] is a sensor that can measure distance, like IR sensor, select the robot's sensor from the list) as X and '8' as Y (Figure 4). The IR sensor expresses the proximity in percentage. In this case 8% means that the object is about 6.5 cm far from the sensor. If the distance between the object and the sensor is less than 6.5 cm the gripper must open.
Figure 4 - The 'Object proximity' block
The next block is a 'Rotate X by Y degrees' block (as you can see on Figure 5), where X is a motor (in this case select motor C) and Y is a degree value. You have to use 1080 degrees to open the gripper enough. So it will rotate motor B clockwise 1080 degrees. After that put a 'wait until X' block again with an 'X > Y' block. Put the same values into X and Y as in the previous one. So the program after opening the gripper will wait for removing the object from the IR sensor.
Figure 5 - Rotating the motor
Finally put the last 'Rotate B by -1080 degrees' block down (Figure 6) You are done and ready to test it. Click on the green flag button, the program starts waiting an object to be near to the IR sensor. Put your hands or something near to the IR sensor and robot's gripper will be open. Then it will wait to remove the object, so put your hands or the object away from the sensor and motor B will be rotated by 1080 degrees counterclockwise, so the gripper will be closed.
Figure 6 - The complete program that grabs and releases objects
More information
- Comment créer une application
- Comment créer un GPC
- Comment créer un fichier persistant
- Comment générer et afficher l'image QR Code
- Installation d'Ozeki 10 sur votre appareil Android
- Contrôle du robot par SMS
- Alerte d'erreur du robot par SMS
- Créez un GPC personnalisé pour améliorer votre interface utilisateur graphique (GUI)
- Dépannage
- Apprenez à utiliser les capteurs du navigateur
- Publiez votre application et gagnez de l'argent
- Appairage Bluetooth
- Dépannage Bluetooth pour Lego Mindstorms EV3
- Ouvrir facilement Ozeki Snap via l'interface graphique
- Ouvrir le bras lorsque l'objet est proche
- Appairage Bluetooth sur les téléphones Android
- Connecter le robot Lego au téléphone
- Discuter avec le robot via le téléphone
- Discuter avec le robot en utilisant un téléphone et un PC
- Comment créer des instructions de construction pour un robot Lego
- Cartographie et navigation