Programming 101 The Common Palette Content provided by Connor Statham (6 th Grade Student)...

38
Programming 101 The Common Palette Content provided by Connor Statham (6 th Grade Student) Formatting by Shannon Sieber

Transcript of Programming 101 The Common Palette Content provided by Connor Statham (6 th Grade Student)...

Programming 101The Common Palette

Content provided by Connor Statham

(6th Grade Student)

Formatting by Shannon Sieber

The Common Palette

MOVE Block

•This block will make your robot move

MOVE Block Function Editor

• Port: the places where your motors are hooked up

• Direction: what direction you want the motors to turn

• Steering: Slows down one motor and speeds up another to make your robot turn.

• Duration: how long, # of rotations (of motor), # of degrees (of motor), seconds, etc.

• Next Action: Do you want a complete stop (BRAKE) or to coast to a stop?

RECORD/PLAY Block

•You can move you’re your robot manually and this will record the actions your robot is taking in a program. You can later play it back.

•Pros: Can come in handy to help troubleshoot

•Cons: It is saved in a temporary file so when you turn off the robot, it is gone, and it takes up a lot of memory

RECORD/PLAY Function Editor

• Action: Are you recording or playing the actions?

• Recording: Which ports are you recording?

• Time: How long are you going to record for?

SOUND Block

• Use this if you would like for your robot to “say” something.

• You can use words already available or create your own files.

• This does take up quite a bit of your memory

• The sounds are not very loud

SOUND Block Function Editor

Action: Sound File-choose from a ready made file or one you provide

Action: Tone-gives you a keyboard to program how long you want certain notes to be played for)

DISPLAY Block

• This block allows you to display things on your NXT Brick

• It is useful when you want to see a how long a count or timer has been going in a program.

• It can also display pictures

DISPLAY Block Function Editor

• Action: choose from an image, text, drawing or to reset the screen

• File: choose what you want displayed

• Position: where on the screen do you want the image, centered, to the left, etc.

WAIT FOR…Blocks

• These blocks make the robot pause until either the time is up or a value is true

Time

Touch

Light

Sound

Distance(ultrasonic)

Choosing what you want to wait for…

Choose if you are waiting for

time or a sensor

Wait for TIME Function Editor

• Until: Decide how many seconds you want the robot to wait.

Wait for the TOUCH sensor Function Editor

• Port: decide where your sensor is hooked up to the NXT Brick

• Action: should the sensor be pressed in, released, or bumped to continue on to the next step

Wait for the value of LIGHT to change Function Editor

• Until: wait until the value of light is greater than or less than a number value you specify

• Function: you can have the sensor generate light if you need it to

Wait for SOUND Function Editor

• Until: the robot will wait until the sound level is higher or lower than your specified value

Wait for DISTANCE (ultrasonic) Function Editor

• Until: The distance is greater than or less than your designated distance. Distance can be measured in inches or centimeters

LoopThe sequence of blocks inside of the loop will repeat over and over or until the value is true

Loop FOREVER

Loop until SENSOR is activated

Loop for a certain amount of TIME

Loop for a certain COUNT

Loop until a value is true (LOGIC)

Loop FOREVER

• Loops over and over and over again.

Loop TOUCH SENSOR

• Loops until a sensor is activated, in this case, TOUCH Sensor

Loop LIGHT SENSOR

• Loops until the value of light is changed

Loop ROTATION SENSOR

• Loops until the rotation sensor has rotated a certain number of degrees or a certain number of rotations.

• You can also reset the rotation sensor with this block

Loop SOUND SENSOR

• Loops until the sound sensor has detected a designated level of sound.

Loop TIMER

• Loops until a timer is greater than or less than a specific value.

• You can also reset the time with this block

Loop for a DISTANCE (ultrasonic)

• Loops until the robot has gone less than or greater than a specified distance.

Loop TIME

• Loop for a specified number of seconds

Loop COUNT

• Loops a certain number of times (e.g. if you put 4, it will repeat the program inside the loop 4 times)

Loop (Logic)

• Loops until a value is true.

• This requires wiring

Switch

• These are like “If…then…else” statements.

• IF this is true, do this, if ELSE, THEN do this.

Switch TOUCH Sensor• IF the touch sensor is pressed,

released or bumped (you select), THEN do what ever your commands are on the top.

• Else, do your commands on the bottom

Switch LIGHT Sensor• IF the value of light is less than or

greater (you decide) a value, THEN do what is the top of your switch

• ELSE do what is the bottom of your switch

Switch ULTRASONIC Sensor

• IF the distance is a certain value, THEN do what is in the top of your switch

• ELSE do what is in the bottom of the switch

Switch ROTATION Sensor

• IF the rotation sensor has gone a specified amount of degrees or rotations, THEN do the top commands,

• ELSE do the bottom commands

Switch TIMER

• IF the timer reads a certain number THEN do the commands in the top,

• ELSE, do the commands in the bottom

• You can also reset the timer

Switch SOUND Sensor

• IF the sound has reached a certain level or below that level, THEN, do the commands in the top

• ELSE, do the commands in the bottom

Switch LOGIC

• IF a value is true/false, THEN do the commands in the top

• ELSE do the commands in the bottom

• Requires Wiring

The END

• You have now completed Programming 101, The Common Palette

• This is a working document so please do not consider it the end all to basic programming with the NXT, but hopefully it will get you a good start.