Download presentation
Presentation is loading. Please wait.
1
MINDSTORMS NXT with JAVA
A guide to getting started Berry Nall Robotics Coach, Roma High School
2
I. Introduction
3
What is leJOS? “leJOS NXJ is a Java programming environment for the LEGO MINDSTORMS NXT ®. It allows you to program LEGO ® robots in Java.”
4
Why would educators use leJOS?
Introduce students to text-based programming Inspire student interest in JAVA, a widely-used programming language Allow students to take advantage of leJOS’ superior performance At the TCEA Region One Advanced Arena competition, the top 3 robots and at least 4 of the top 6 finishers were programmed using text-based programming (leJOS or RobotC).
5
Other Advantages of leJOS
(compared to NXT) Faster loading and program execution Programs use less memory Greater accuracy Scalable Free!
6
Who can learn to use leJOS?
Anyone here (and your students) can learn enough to program for a TCEA competition. We hope some of our students will go far beyond what we can do.
7
II. Eclipse IDE An Integrated Development Environment is a program that allows you to write (and run) programs.
8
Uploading leJOS to the brick
9
If something goes wrong?
The brick will most likely make a ticking noise. 1. Reinstall the NXJ software using the LEGO-supplied program. 2. Upload the leJOS software again.
10
Exploring Eclipse Upload program Locate program files Edit program
Upload status
11
Eclipse helps This view is saved as the “leJOS” perspective.
In Eclipse, the view is called a “perspective.” Students may change it accidentally, causing confusion. This view is saved as the “leJOS” perspective. To restore, click “Window”, then choose “Reset perspective” Current perspective
12
Eclipse helps Eclipse tells you if there is a typing error or an illegal command:
13
Eclipse helps Click here to load a program:
14
III. JAVA basics
15
JAVA Rules to remember Capitalization matters! Ex: tcea is not TCEA is not tCeA Every command ends with a semicolon // means you are inserting a comment; everything after the slashes is ignored
16
IV. Writing programs
17
Program Sections Import statements File name Define pilot, sensors
import lejos.nxt.*; import lejos.robotics.navigation.*; import lejos.util.Stopwatch; /** *comment to name author (please change!) * */ public class TCEA { //Variables and declarations go here public static void main(String[] args) // program goes here } File name Define pilot, sensors Commands for robot to follow
18
To start: modify TCEA.java for your robot
Experimentally determine the wheel diameter. Make the “travel” statement a comment and remove the comment slashes from the “rotate” statement. Experimentally determine the wheel base. Note: the wheel base may need to be modified for different surfaces or designs even if the actual size doesn’t change.
19
Test your robot: TCEA1rectangle.java
If the wheel diameter and wheelbase are set correctly, the robot will travel in a rectangle and arrive where it started.
20
To program your robot: save the modified TCEA.java with a new name.
Change the class to the name of your file. Add commands to make the robot move.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.