28
Introduction to Programming

Introduction to Programming

  • Upload
    bayard

  • View
    23

  • Download
    0

Embed Size (px)

DESCRIPTION

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!. - PowerPoint PPT Presentation

Citation preview

Introduction to Sensors and Programming

Introduction to ProgrammingOverview 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!

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

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

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.) Programming Blocks

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

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

MoveMotors that are being used in this blockType of measurement (degrees is usually best)DirectionApprox. power levelMotors that are being used in this block. Note that multiple can be used.Power levelRotation of wheels (use degrees)Steering:Far sides create pivot turn (ex. Motor C forward, motor B backwards) the middle goes straight, and then everything in between.

MotorMotor that is being used in this block (limit of one)Type of measurement (degrees is usually best)DirectionApprox. power levelMotor that is being used in this blockPower levelRotation of motor (use degrees)If checked, wait to do the next task until this is complete, if unchecked, do the next task while this is still going

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

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.)

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

Switch: Touch 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 symbolSensor changing areaAction: 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!)Port of sensor

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)(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 symbolSensor changing areaCompare: 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 , which can be changed to a