Example Code

Daniel-san: A simple object grabbing robot for Lego NXT

Code and Documents

Attachment

Introduction

For an inter-office NXT competition, I was tasked to build a robot that could grab an object from the field and then place it in the scoring area.  I ended with a robot that could go and search for an object and return to homebase (which I could then touch the robot, as per our rules) and then point it towards the scoring area to drop the ball.

I ended up with some pretty simple NXT code, but it will showcase some of the Beta NXT Module.  I present Daniel-san (homage to the Karate Kid)

danielsan_mainbd.png

danielsan_getballbd.png

danielsan_scoreballbd.png

Additional Notes

The robot works by:

- Waits for user input to determine whether to get the ball or score the ball

- Upon completion of a task, a sound file is played to show that it's "The Best...Around!"

- Uses the built-in encoder to determine distance traveled and to help return the robot to homebase

- A sonar sensor determines the distance of the robot to the object and a light sensor determines if an object has been acquired by the claw.

I would include a picture of the robot, but it was dismantled to be used for Lego Mentoring.  Stay tuned for more NXT Module Code!

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors