ProgrammingA program is like a recipe-- it specifies a list of operations that the computer (robot) should perform.
Some programs are just a linear list of operations
More complex programs will have conditional branches and repetitive loops.
Mindstorm Programming
There are two sensors on the robots, a touch sensor and a light sensor.
Touch sensor: You can program the robot to perform operations in reaction to the events such as 'the robot hitting a wall' Light sensor: You can also have the robot perform an operation while it is over a certain color, and then do something different if it is over another color. For instance, you can program the robot to drive around a black track on a white background.
Mindstorm Blocks Dealing with Sensors:
Wait: You can program the Wait block so that a robot does whatever its doing until it senses something. For instance, you can have start its motor moving forward, then wait until the touch sensor is pressed, then do something different;
MOVE FORWARD (UNLIMITED) WAIT UNTIL TOUCH SENSOR MOVE BACKWARD 3 SECONDS
If you put blocks like the above within a loop, your robot would move to a wall, Hit it, start moving backward for three seconds, then go forward again.
Switch: You program a switch block to have the robot do a different thing depending on a sensor. For instance, you can have it move straight on one color and turn on another
Loop: You can program a loop block so that it continues looping until the robot senses some condition.
Sensor CalibrationThe
light sensors can be calibrated so that you get better readings. If you're having difficulties, Choose
Tools | Calibrate Sensors, select Light Sensors and the proper port,
then click on 'calibrate'. This will download a program to your robot.
Next,
run the program that is downloaded. The screen will ask you to place the robot over a
minimum and maximum value for light-- just place the sensor over a
white and black sheet for the two questions. Be sure that the screen
reports numbers that make sense (e.g., 300 and 600) Problems1. Write a program in which the robot moves forward until it hits something, then moves backward three seconds, then begins moving forward again until it hits something again. Continue forever.
2. Write a program in which the robot moves forward until it hits something, backs away for one second, then turns around (180 degrees) and moves until it hits something again. Continue forever.
3. Write a program in which the robot moves forward/backward on a black line. When it gets to the end of the line it should say something then switch direction and keep going until it hits the other end of the line. Run the robot on a Mindstorm map for best results.
4. Write a program in which the robot drives around a circular track.
|
|