1 / 28

Introduction to Programming

Introduction to Programming. Overview of NXT Programming. This is the first thing you see when you open the program. Name your file here and then push go to start!.

bayard
Télécharger la présentation

Introduction to Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Programming

  2. Overview of NXT Programming

  3. This is the first thing you see when you open the program. Name your file here and then push go to start!

  4. The program defaults to only showing the Common Palette, which only has some basic functions. To change to the Complete Palette click here.

  5. The color of the block tells which palette it is from, but some things on the common palette are also found in others. Common Action Sensor Flow Data Advanced

  6. The pointer allows you to select blocks. The pan tool allows you to move the workspace around. The comment tool allows you to make text comments in the workspace (helpful for long and/or confusing programs.)

  7. Programming Blocks

  8. These are various types of blocks. They are what you use to program your robot.

  9. This panel displays more information about the block you currently have selected. The name of the current block is found here.

  10. Move Motors that are being used in this block Type of measurement (degrees is usually best) Steering: Far sides create pivot turn (ex. Motor C forward, motor B backwards) the middle goes straight, and then everything in between. Direction Approx. power level Motors that are being used in this block. Note that multiple can be used. Rotation of wheels (use degrees) Power level

  11. Motor Motor that is being used in this block (limit of one) Type of measurement (degrees is usually best) Direction Approx. power level If checked, wait to do the next task until this is complete, if unchecked, do the next task while this is still going Motor that is being used in this block Rotation of motor (use degrees) Power level

  12. In general, the plain sensor blocks are not very useful.

  13. The sensors are best used to allow the robot to make a decision based on its environment, so a Switch Block is a better choice. (They are found in the flow palette, and the sensor to be used defaults to touch, but can be changed via the drop down menu in the panel.)

  14. A switch block tells the robot to make a choice based on an input it has. Some people call this a “fork” because the path splits into two options, but only one is selected. For example, if we read the program like a book it might read, “Is it dark in here? If yes, then I will… If no, then I will…” or “Is my button being pushed? If yes, then I will… If no, then I will…”

  15. Switch: Touch Sensor Port of sensor (All of top row) Commands that will happen if the action (circled) happens (in this case, the button is pressed) (All of bottom row) Commands that will happen if the action (circled) happens (in this case, the button is not pressed) Touch sensor symbol Action: This will change the symbols in the block graphic and tells the robot what to base a decision off of. Port (make sure the touch sensor is in this port!) Sensor changing area

  16. Switch: Sound Sensor (All of top row) Commands that will happen if the action (circled) happens (in this case, the sound is louder than the value) Port of sensor (All of bottom row) Commands that will happen if the action (circled) happens (in this case, the sound is less than the value) Sound sensor symbol Compare: This will change the symbols in the block graphic and tells the robot what to base a decision off of. Notice the >, which can be changed to a <. When a value is entered, the robot checks if the sound it is receiving is more or less than that, and acts based on it. Sensor changing area Port (make sure the sound sensor is in this port!)

  17. Switch: Light Sensor (All of top row) Commands that will happen if the action (circled) happens (in this case, the reflected light is more than the value) Port of sensor (All of bottom row) Commands that will happen if the action (circled) happens (in this case, the reflected light is less than the value) Light sensor symbol Compare: This will change the symbols in the block graphic and tells the robot what to base a decision off of. Notice the >, which can be changed to a <. When a value is entered, the robot checks if the reflected light it is receiving is more or less than that, and acts based on it. This turns on the little red light in order to reflect back. Port (make sure the light sensor is in this port!) Sensor changing area

  18. Switch: Light Sensor Port of sensor (All of top row) Commands that will happen if the action (circled) happens (in this case, something is closer than the value) (All of bottom row) Commands that will happen if the action (circled) happens (in this case, nothing is closer than the value) Ultrasonic sensor symbol Compare: This will change the symbols in the block graphic and tells the robot what to base a decision off of. Notice the <, which can be changed to a >. When a value is entered, the robot checks how far away its ultrasonic can reach before hitting an object, then compares it with the value entered, and acts based on it. Use Centimeters! Port (make sure the light sensor is in this port!) Sensor changing area

  19. Example A program like this says: “Go forward 360 degrees, then check if the ground is dark or light. If it is light, then go forward 360 degrees more, if it is dark, then go backwards 360 degrees. After all of that, move motor A 360 degrees.”

  20. Loops: Forever In general, loops just tell the robot to repeat what is inside the loop. This can be set to go on forever, or have a certain condition to stop. This is a forever loop. The program will repeat until you turn the robot off.

  21. Loops: Sensor This is a sensor loop. The sensor can be changed, just like a switch. The program will repeat until the condition is true. These work similarly to a switch, except that if the condition is met, the loop stops and the next block is performed, and if it is not met, the robot repeats what is in the loop, essentially “trying again” until it gets it right. In this case, the robot will move forward 360 degrees and look for an object closer than 127 cm. If there is none, it will move forward 360 degrees again and check again, until it detects an object closer than 127 cm, then it will break out of the loop and go backwards 360 degrees.

  22. Loops: Count This is a count loop. It just repeats the task the number of times it is told to, then will break out of the loop.

  23. This is a loop with an empty switch inside of it. This is an empty loop. It looks like this when you get it from the flow palette. These things can compile into lots of crazy jumbled mess, but if you look at it slowly (and with the help of the pan tool) it isn’t so bad.

  24. Downloading and Updating

  25. If your NXT is on, plugged in, and connected via USB, you can name it and check the battery power here. You can see what is currently on your NXT under the memory tab here. The NXT does not hold very much, so a complicated program will not be able to have sounds, because there is not enough memory. NXT Window Download: Put onto the NXT to run by pushing a button (usually a good choice) Download and Run: Put on the NXT and run immediately

  26. If you get an error message with something like “Update NXT firmware” Then plug in the NXT via USB, turn it on, go to the tools tab and click here. Then click Download and wait until your NXT beeps.

  27. Tips • If the program is not working how you expect it should, click on each block, reading it aloud as a story, ex. “First the robot will move forward with motors B and C 360 degrees, then will decide if an object is closer than 50 cm away,” etc. It helps to find small errors. • If the robot seems to be “stalling” in the middle of a program and you can’t find the error, insert various sound blocks to make sure the program is getting as far as you think it is, or where it is messing up.

  28. THE END! YAY!

More Related