Icons & Hints | Examples |
Hints: This behavior is Go Straight. This behavior is written for a two motor car. In any behavior, you can modify the code to fit your needs. | This code turns motors A and C on in the forward direction for 1 second, then turns off the motors. |
Hints: This behavior is Turn. This behavior is written for a two motor car. In any behavior, you can modify the code to fit your needs. | This code turns motor A on forward and motor C on backward. After 0.25 seconds, the motors are turned off. |
Hints: This behavior is Lurch. It makes the car go forward then stop then go forward again a number of times. This behavior is written for a two motor car. In any behavior, you can modify the code to fit your needs. | In this code, motors A and C are set to go in the forward direction. Then a loop begins that turns the motors on for one second, then off for one second. This loop repeats 10 times. |
Hints: This behavior is Snake. It makes the car turn from side to side a number of times. This behavior is written for a two motor car. In any behavior, you can modify the code to fit your needs. | This code first sets the motors for a power level of 5 (the default). Then it sets motor A's direction to backward and motor C's direction to forward. It then enters a loop which turns the motors on for one second, then reverses their directions. This loop repeats 10 times. |
Hints: This behavior is Drive to Bump. It makes the car drive forward until a touch sensor is pushed. This behavior is written for a two motor car. In any behavior, you can modify the code to fit your needs. | This code turns on motors A and C in the forward direction. When touch sensor 1 is pushed, motors A and C turn off. |
Hints: This behavior is Drive to Dark. It makes the car drive forward until the light sensor reading drops. This behavior is written for a two motor car. In any behavior, you can modify the code to fit your needs. | This code turns on motors A and C in the forward direction. When the light sensor reading falls by five (the default), motors A and C turn off. |
Hints: This behavior is Two Button Remote. It allows you to control the direction your car drives with two touch sensors. This behavior is written for a two motor car. In any behavior, you can modify the code to fit your needs. | This code is written for the motors to be connected to ports A and C and touch sensors to be connected to ports 1 and 2. A task split is used so that each motor is controlled by one touch sensor in a separate task. Each tasks consists of a forever loop and a touch sensor fork. When a touch sensor is pressed, that motor turns on in the forward direction. So, when both touch sensors are pressed, both motors go forward, causing the car to drive straight. When neither touch sensor is pressed, both motors are stopped, causing the car to stay still. If only touch sensor 1 is pressed, then only motor A is on, causing the car to turn. |
Hints: This behavior is Stay Still. It makes the car stay in the same place. If you push it, it will return to the original spot. This behavior is written for a one motor car with an angle sensor attached to a second set of wheels. In any behavior, you can modify the code to fit your needs. | This program begins by resetting the angle sensor (which sets the original spot the car will try to return to). Then a forever loop begins. In this loop, The value of the rotation sensor is multiplied by 5, and this value is used for motor speed. In this way, the car will return to the original spot (0 rotations, moving at speed 0, or stopped) if it is pushed. If you find that your car runs away from you - reverse the direction of the motor of change the container multiplier to a negative number. You can adjust the sensitivity of the proportional control by adjusting the multiplier. |
Hints: This behavior is Drive and Sing. It makes the car drive forward while playing a song. This behavior is written for a two motor car. In any behavior, you can modify the code to fit your needs. | This program uses a task split so that the car can drive and play a song at the same time. The top task turns on motors A and C in the forward direction. After 5 seconds, it turns the motors off. The bottom task plays the red scroll. After the red scroll finishes, all outputs (the default) are turned off. |
Hints: This behavior is Sing until Dark. It causes the RCX to repeat a song until the light sensor reading drops below a specified value. The code uses an event to monitor for the drop in light sensor reading. Therefore, the reading must begin or rise above the cutoff before an event can be triggered by the drop in light sensor reading. In any behavior, you can modify the code to fit your needs. | This program uses an event to trigger the end of the song. A light sensor event is set up as the red event and is looking for the light sensor reading to fall below 55. Next, the program begins monitoring for the red event. The red scroll is played in a forever loop. When the light sensor reading falls below 55, the event will be triggered, ending the program and the song. |
Hints: This behavior is Sample Light. Use this to behavior to collect light sensor data.In any behavior, you can modify the code to fit your needs. | This program initializes light sensor data logging, then logs data every 0.1 seconds. This continues until 50 data points have been collected, then data logging stops. |
Hints: This behavior is Sample and Drive. Use this to behavior to collect light sensor data while driving. This behavior is written for a two motor car. In any behavior, you can modify the code to fit your needs. | This program turns on motors A and C in the forward direction.It then initializes light sensor data logging, and logs data every 0.1 seconds. This continues until 50 data points have been collected, then data logging stops. Finally, the outputs are turned off. |
Hints: This behavior is Position Control. It allows for much greater precision in car movement. The constant and distance can be varied. This behavior is written for a one motor car. In any behavior, you can modify the code to fit your needs. | This program begins by optimizing RCX behavior and resetting the angle sensor. The proportionality constant, Kp, is set up as 10.5. Then a loop begins in which the value of the angle sensor is placed in the red container, and motor A is turned on by a power level that is computed by subtracting the red contained from 32 and multiplying by the proportionality constant, Kp. After a 0.05 delay, the loop is repeated. The loop repeats 400 times and then motor A is turned off. |