Difference between revisions of "NXT Logo Examples: A simple interactive control of NXT-G program from Imagine using files"
(New page: In this project, we build a robot that has an ultrasonic distance sensor on the front and keeps a required distance from the wall: when the distance is lower, the robot moves back, when it...) |
m |
||
Line 1: | Line 1: | ||
In this project, we build a robot that has an ultrasonic distance sensor on the front and keeps a required distance from the wall: when the distance is lower, the robot moves back, when it is larger, it moves forward. In this way, the robot is also able to follow a person in a required distance, or go back when somebody approaches the robot... | In this project, we build a robot that has an ultrasonic distance sensor on the front and keeps a required distance from the wall: when the distance is lower, the robot moves back, when it is larger, it moves forward. In this way, the robot is also able to follow a person in a required distance, or go back when somebody approaches the robot... | ||
− | [[Image:keep_distance_with_slider_robot.png]] | + | {| cellspacing=30 | |
− | + | | [[Image:keep_distance_with_slider_robot.png]] | |
− | We would like to make the program in such a way that we can interactively regulate this distance using a slider. | + | | We would like to make the program in such a way that we can interactively regulate this distance using a slider. Thus in Imagine Logo, we create a slider (it will get a name s1): |
− | Thus in Imagine Logo, we create a slider (it will get a name s1): | ||
[[Image:keep_distance_with_slider_imagine_slider.png]] | [[Image:keep_distance_with_slider_imagine_slider.png]] | ||
Line 21: | Line 20: | ||
end | end | ||
+ | |} | ||
Finally, we need some program for the robot so that it will keep the distance according to the value in the file. | Finally, we need some program for the robot so that it will keep the distance according to the value in the file. | ||
This time, we make that program using standard NXT-G programming environment, and it will look as follows: | This time, we make that program using standard NXT-G programming environment, and it will look as follows: | ||
+ | |||
[[Image:keep_distance_with_slider_nxt_g_program.png]] | [[Image:keep_distance_with_slider_nxt_g_program.png]] | ||
+ | |||
The robot repeats a loop: read a value from file, close the file, then read the value of the ultrasonic distance sensor on port 4, and finally compare the sensor readings with the value that was read from the file. Depending on the result of the comparison, the robot moves forward or backs up. | The robot repeats a loop: read a value from file, close the file, then read the value of the ultrasonic distance sensor on port 4, and finally compare the sensor readings with the value that was read from the file. Depending on the result of the comparison, the robot moves forward or backs up. |
Revision as of 02:51, 24 March 2009
In this project, we build a robot that has an ultrasonic distance sensor on the front and keeps a required distance from the wall: when the distance is lower, the robot moves back, when it is larger, it moves forward. In this way, the robot is also able to follow a person in a required distance, or go back when somebody approaches the robot...
Finally, we need some program for the robot so that it will keep the distance according to the value in the file. This time, we make that program using standard NXT-G programming environment, and it will look as follows:
The robot repeats a loop: read a value from file, close the file, then read the value of the ultrasonic distance sensor on port 4, and finally compare the sensor readings with the value that was read from the file. Depending on the result of the comparison, the robot moves forward or backs up.