Pengenalan Program

programming

Tampilan untuk pemrograman adalah seperti gambar diatas, untuk mengetahui penjelasannya dapat dilihat pada link berikut : pemrograman

Hal pertama yang harus diketahui adalah penggerakan motor , berikut ini beberapa hal penting tetang pergerakkan motor (dalam bahasa inggris ):

Straight Move

  1. The first block is a ‘start’ block.
  2. The second block is a ‘move steering’ block with mode set to ‘rotations‘. The steering value is set to zero, so the robot will move in a straight line, the power is set to +50 so the robot will move forward at 50% power, the number of rotations is set to two and the option to apply the brake after the motion is ‘on’. Thus this block will make the robot move two wheel rotations forwards in a straight line. Note that the blue ovals in the images highlight values that have been changed from their default values.
  3. The third block is a ‘wait’ block. Its mode is set to ‘time’ and the time is set to one second, so the robot will pause for one second.
  4. The fourth block is a ‘move steering’ block with mode set to ‘degrees‘. The steering value is set to zero, so the robot will move in a straight line, the power is set to -50 so the robot will move backwards at 50% power, the angle is set to 720 degrees (two rotations) and the brake option is ‘on’. Thus this block will make the robot move two rotations (of the wheels) backwards in a straight line, bringing the robot back to its starting position. Be clear in your mind that the angle (or number of rotations) refers only to the motors (and the wheels in this case) but NOT THE ROBOT which will turn through some other angle, as seen from above. Note also that setting the power to +50 and the angle to -720° would have had the same effect as in the above program, but that setting both the power and the angle negative would cause the robot to move forwards.
  5. The fifth block is a ‘wait’ block, set like block 3 to make the robot pause for one second.
  6. The sixth block is a ‘move steering’ block with mode set to ‘seconds‘. The steering value is set to zero, so the robot will move in a straight line, the power is set to +50 so the robot will move forward at 50% power, the number of seconds is set to one and the brake option is set on. Thus this block will make the robot move forwards in a straight line at 50% power for one second.

Curved Move

  1. ‘Start’ block.
  2. ‘Move steering’ block with mode set to ‘degrees‘. The steering value is set to +100, so the robot will turn ‘hard right’, the power is set to +40%, the angle is set to 685° (1.9 rotations) and the brake option is on. Thus this block will make the robot turn hard right until each wheel has turned 1.9 rotations (the left wheel will turn forwards through that angle and the right wheel will turn backwards through the same angle).
  3. ‘Wait’ block with mode set to ‘time’. The time is set to one second so the robot will pause for one second.
  4. ‘Move steering’ block in ‘degrees‘ mode. The steering value is set to 50 so the robot will move make a medium turn right (with the right wheel not turning), the power is set to +40% (for the left wheel), the angle is set to 1380° (3.83 rotations) and the brake option is on. Thus this block will make the robot do a medium turn right, with the left wheel turning 3.83 rotations and the right wheel not turning.
  5. ‘Wait’ block, set like block 3 to make the robot pause for one second.
  6. ‘Move steering’ block in ‘rotations mode. The steering value is set to 25% (a gentle right turn), the power is set to +50 so the left motor will turn at 50% power (the right motor will turn at 25% power, if you think about it). The number of rotations is set to two and the brake option is on. Thus the robot will gently turn right until the left wheel has turned through two rotations.

Overall then, this program makes the robot do a hard turn right, then a medium turn right, then a gentle turn right.

Tank Move

  1. ‘Start’ block.
  2. Move tank‘ block with mode set to ‘degrees‘. The ‘power left’ value is set to +40, and the ‘power right’ value is set to -40 so the robot will turn ‘hard right’ at 40% power. The angle is set to 685° so each motor (and wheel) will turn 685° (1.9 rotations) with the left motor turning forwards and the right motor turning backwards. The brake option is on. Thus this block will make the robot turn hard right with each wheel turning through 1.9 rotations.
  3. ‘Wait’ block with mode set to ‘time’. The time is set to one second so the robot will pause for one second.
  4. ‘Move tank’ block in ‘degrees‘ mode. The ‘power left’ value is set to +40, and the ‘power right’ value is set to zero so the robot will turn ‘medium right’ with the left wheel at 40% power and the right wheel not turning. The angle is set to 1380° so the left motor (and wheel) will turn 1380° (3.83 rotations). The brake option is on. Thus this block will make the robot turn medium right with the wheel block turning 3.83 rotations and the right wheel not turning.
  5. ‘Wait’ block, set like block 3 to make the robot pause for one second.
  6. ‘Move tank’ block in ‘rotations‘ mode. The ‘power left’ value is set to +50, and the ‘power right’ value is set to +25 so the robot will turn ‘gentle right’ with the left wheel at 50% and the right wheel at 25% power. The number of rotations is set to two so the left motor (and wheel) will turn two rotations (the right wheel will turn 1 rotation, if you think about it). The brake option is on.

Overall then, this program makes the robot do a hard turn right, then a medium turn right, then a gentle turn right. It is exactly equivalent to the previous program, except that it uses ‘move tank’ blocks instead of ‘move steering’ blocks.

Move Object

  1. ‘Start’ block.
  2. This ‘medium motor’ block indicates ‘A’ in its header so it will control the medium motor attached to port A. Its mode is set to ‘angle’. Its power is set to -30 so it will turn ‘backwards’ at 30% power. The angle is set to 100°. In the standard ‘driving base’ model the medium motor is attached to a gripper which is assumed to start in a vertical position – this block will cause the gripper to be lowered to the ground, hopefully enclosing an object within its grip as it does so.
  3. ‘Move tank’ block with mode set to ‘degrees’. The ‘power left’ value is set to -50%, and the ‘power right’ value is set to zero so the robot will turn ‘medium left’ (anticlockwise as seen from above) with the left wheel turning backwards at 50% power and the right wheel not turning. The angle is set to 360° so the left motor will turn one rotation (backwards). The brake option is on.
  4. ‘Medium motor’ in ‘degrees’ mode. The power is set to +30 so it will turn ‘forwards’ at 30% power. The angle is set to 100°, so this block will cause the gripper to be raised back into the vertical position.

Overall then, this program makes the robot lower the gripper bar, trapping an object, then it does a medium left turn backwards, pulling the object with it, then it raises the gripper bar.

Stop at line

This exercise assumes that a colour sensor is attached to port 3 and is suspended just above the ground, pointing at the ground, as in the photos at the top of this page.

  1. ‘Start’ block.
  2. This ‘large motor’ block indicates ‘C’ in its header so it will control the large motor attached to the right wheel. Its mode is set to ‘on’ so the motor will run continuously until another block stops it. Its power is set to +50 so it will turn ‘forwards’ at 50% power.
  3. ‘Wait’ block with mode set to ‘colour sensor>compare>reflected light intensity’. What is the difference between ‘compare’ and ‘change’?  ‘Compare‘ works with the absolute value of the brightness, testing for example whether the brightness exceeds a certain absolute value. ‘Change‘, as the name suggests, uses the change in the brightness, testing for example whether the brightness has changed by more than a certain amount. Our block is set to ‘compare’ so it will wait for the reflected light intensity to reach a certain value, rather than a certain change of value. The compare type is set to ‘less than’ (option 4) and the threshold value is set to 50% (relative to some maximum value which is a property of the sensor hardware). So this block will wait until the brightness is less than 50%. Note that just because the wait block’s condition has been met, it does not cause the motor to stop, it just allows the program to move to the next step.
  4. ‘Large motor’ block in ‘off’ mode. The brake option is on, so this block simply turns the motor off and applies the brake.

Overall then, this program turns on the right motor (making the robot turn left), then waits until the brightness falls below a certain value (because the sensor has passed over a black line, for example) then turns off the motor.

Stop at angle

This exercise uses the gyro sensor, which is assumed to be connected to port 2. The gyro sensor measures the angle in which it is pointing, relative to the angle that is was at when the program was launched. It’s very important to keep the Gyro Sensor and EV3 steady when connecting the cable and during start-up of the EV3, otherwise the gyro reading will continually wander away from the correct value. If you are not sure that this condition was met then simply unplug the sensor from port 2 and then reconnect it before running the program, while ensuring that the EV3 and the gyro sensor are very still.

  1. ‘Start’ block.
  2. ‘Move tank’ block with mode set to ‘on’. The power left’ value is set to +40, and the ‘power right’ value is set to zero so the robot will turn ‘medium right’ continuously at 40% power.
  3. ‘Gyro’ block with mode set to ‘change>angle’. The direction is set to ‘increase’ (option 0) and the angle is set to 45°, so the block will cause the robot to wait until the robot has turned 45° in the positive direction (clockwise, as seen from above). Note that the gyro measures the rotation of the robot as seen from above (if the gyro is fixed horizontally, as here) and not the rotation of the motors or the wheels).
  4. ‘Move tank’ block in ‘rotations’ mode. Both power values are set to +50 so the robot will move forwards in a straight line. The number of rotations is set to 1 and the brake option is on.

Overall then, this program makes the robot do a continuous medium right turn until the gyro detects that the robot has turned through 45°, then the robot moves straight until the wheels have turned through one rotation.

Stop at object

  1. ‘Start’ block.
  2. ‘Move steering’ block with mode set to ‘on’. The steering value is set to zero so the robot will move continuously in a straight line. The power is set to +50%.
  3. ‘Wait’ block with mode set to ‘ultrasonic sensor>change>distance in centimeters’. The direction is set to ‘decrease’ (option 1). The amount (of the decrease in cm) is set to 11. Thus this block will make the program wait until the distance between the robot and the reflecting object has decreased by 11 cm (because the robot is moving towards it).
  4. ‘Move steering’ block in ‘off’ mode, with brake option on. This blocks simply stops the motors B and C and applies the brake.
  5. ‘Wait’ block, set to make the robot pause for one second.
  6. ‘Move steering’ block in ‘on’ mode. The steering value is set to 0 (straight line) and the power is set to -50 so the robot will go continuously backwards rather than forwards.
  7. ‘Wait’ block with mode set to ‘ultrasonic sensor>change>distance in centimeters’. The direction is set to ‘increase’ (option 0). The amount (of the increase in cm) is set to 6. Thus this block will make the program wait until the distance between the robot and the reflecting object has increased by 6 cm (because the robot is moving away from it).
  8. This last block is the same as block 4 – it simply stops the motors B and C and applies the brake.

To summarize, the robot will move forward in a straight line until it has moved 11cm closer to the reflecting object in front of it, then it will stop and pause for one second, then it will back up continuously until it detects that it has moved 6cm away from the object, then it will stop.

 Silakan coba dengan menggunakan berbagai metoda yang ada.

Leave a Reply

Your email address will not be published. Required fields are marked *