How to build and program a lego robot




















Basic Movements. Check out this video to learn how you create a program that makes your robot move. The touch sensor makes your robot react when you push or release sensor in front. Check out this video to learn how it works. Make Your Robot Drive Take your robot for a spin! The App contains only the basic blocks and it does not have the yellow sensor blocks, blue advanced blocks and red data operations blocks. If you would like detailed instructions on the installation process, see our post here.

If you are using a tablet, then Bluetooth is the only option. If your machine does not have Bluetooth, then I would recommend purchasing a cheap Bluetooth dongle like this one on Amazon. This process only ever needs to be done once, i. The EV3 Brick will make an audible beep as it connects, select the checkbox on the EV3 brick to confirm.

To do this:. OnFwd x,y is an already written program that will move the wheel forward. Notice that after the command, there are two inputs. The x refers to the motor that the command will be sent to. The y refers to the percentage that you want the motor to move at. The next line will be for how long you want the robot to move for in milliseconds. The command for this is Wait z. So if we want the robot to move for 5 seconds, we would input We will then turn the motors off.

This command is Off x. Write this code twice for both motors on separate lines. After turning off the motors, typing Continue z will shut them off for a certain amount of time before the Brick reads the next line of code. For the program to output this code, place a ; after each line of code. If the ; is not there the program will not run properly and the Brick will be overloaded.

Next we will move the robot backwards. For the bot to go backwards the command is OnRev x,y the inputs are the same as in the previous step. To make it easier on us, we can start both motors at the same time. In step 18, we created two separate steps to turn the motors on.

The next line of code will have the time commitment. We will again leave it a 5 seconds. The command is the same as previously stated. Wait for the motors to move the wheels for 5 seconds. When the robot is done moving, we want to turn the motors off. We can combine the multiple steps that were used in step 18 to turn the motors off into one step by using the same shortcut we used earlier in this step.

This turns both motors off at the same time. To finish the program, we need to close it out. The finished code will look similar to the figure above. The figure has comments as to what the robot will do during each section of code.

We did not talk about how to do that in these instructions. We have now built the robot. We have created a program that will make the robot move. Now all we have to do is get the robot to move. First we need to compile the program so that it can be read by the Brick.

On the main screen of BricxCC there is a group of four buttons and a drop down menu. It will look like the figure below. The farthest left button will compile the program, the second to the left will download and rewrite into binary for the Brick, the drop down menu should show the name of your program, the second from the right is the run button, the farthest right is the stop button.

Assuming there were no errors in the program click the second to the left button. This will download the program to the Brick. If there are errors, you will be notified of them. This will run the program from the Brick. Congratulations, were finished! Did the robot do what we wanted?

If not make sure to check the wiring to make sure the cables are connected to the correct ports. If there were errors in the program, check what you have written with mine from step If everything went to plan, you have built a NXT Lego robot.

You have written the program that will move the bot. If the code was written correctly, the bot would have moved forward for five seconds, then waited another five seconds before going backwards for five seconds. If the timing needs to be changed, more or less time can be added. If the direction needs to be changed to go right or left, only one of the motors needs to be turned on for a certain amount of time.

Now you know how to change up the code for changing direction as well as timing. Reply 8 years ago on Introduction. It really depends on the kit that you purchase.



0コメント

  • 1000 / 1000