ROBOTC for Mindstorms is an Integrated Development Environment. It has been developed to provide as much support as possible for the platforms it is compatible with. RobotC extends the ‘C’ Programming Language with a number of built-in variables and functions to provide control over a robot’s hardware devices, i.e. the motors and sensors. In this project, a Lego robot was created, consisting of four sensors: an ultrasonic sensor, color sensor, and compass sensor. Using these four sensors, the robot’s objective was to move around, and avoid bumping into the wall. While moving around, if the robot encountered a blue ball in sight, then the robot is programmed to kick the ball toward the north direction.
Johnny 5 Jr. Procedure
Hardware – The color sensor was placed in front of the robot to detect whether the blue ball was in range. Then, the ultra-sonic sensor was installed slightly above the color sensor in order for the robot to detect the wall and other obstacles. Next, a motor was installed so the robot can kick the ball. Finally, a compass was installed in order for the robot to kick the ball North.
Software – For this program, we had 4 tasks and 2 functions.
Johnny 5 Jr. Functions
int hold(int ms) – waits for a specified number of milliseconds without interfering with the sensors.
void kickBall() – kicks ball north
moverandom() – moves the robot randomly
avoidWall() – checks the ultrasonic sensor to avoid the wall by reversing and turning
findBall() – checks the color sensor to see if ball is in range
main() – initialize sensors and start all other tasks
Johnny 5 Jr. Technologies
LEGO MINDSTORMS NXT
Johnny 5 Jr. Conclusion
Programming robots is more challenging than writing a normal computer program. The environment that the robot moves around in is unpredictable. The programs written for the robot to operate deeply rely on external hardware.