Monday, August 30, 2010
Tutorial on Building a Thermostatic Sensor for your NXT
In this video, I take you step-by-step through the process of creating a thermostatic sensor for your NXT. Enjoy!
Saturday, August 28, 2010
The NXT as a Home Thersomstat using the HiTechnic Experimenter's Kit
In my next blog entry, I'll show you how to use the NXT with the HitTechnic Experimenter's Kit to construct a household thermostat. I am currently making the video. I'll have code and a circuit diagram to show you. Stay tuned!!!
Monday, August 23, 2010
Monte Carlo Localization and Code Tutorial
I have been asked to explain how the MCL class works. Rather than giving a long written explanation, I've chosen to give a video tutorial. Remember that the source code that I am referring in the video is available for download.
Enjoy!
Enjoy!
Tuesday, August 17, 2010
Build your own Sound Meter with Lights
Using the HiTechnic Experimenter's Kit, you can easily create a sound meter with lights. Here is my YouTube video illustrating how this can be done! Download the source code.
Monday, August 16, 2010
Robot Building Instructions
I have been asked what robot design I use. Actually, I use the Robot Educator Model courtesy of Carnegie Mellon University's Robot Academy. It's a simple design and it can be constructed quite easily and rapidly.
Sunday, August 15, 2010
Lejos and the HiTechnic Experiment Kit
I recently purchased the HiTechnic Experiment Kit. I'm having a lot of fun with it. Even though the code for the eight experiments is written in NXT-G and NXTC, I have found that the kit is perfectly suitable for use with Lejos. You can download my example code for Experiments 1 and 2 as shown in the book that comes with the kit.
Also, please view my video tutorial, which explains Experiment 2 in detail, including the code that supports it. The experiment deals with having the NXT control 6 LEDs based upon the setting of a potentiometer.
It's a product certainly worth purchasing!
Also, please view my video tutorial, which explains Experiment 2 in detail, including the code that supports it. The experiment deals with having the NXT control 6 LEDs based upon the setting of a potentiometer.
It's a product certainly worth purchasing!
Saturday, August 14, 2010
Customizing the GUI
I have been asked how to change the GUI’s connect panel to change the name and Bluetooth address of the NXT or NXTs you want to connect to.
In the ConnectPanel.java file, you need to change these two lines of code:
In my particular case, my NXTs are called MONTE and Wayfinder; their Bluetooth addresses are 00:16:53:00:57:37 and 00:16:53:08:82:3a respectively.
For example, if your NXT is called Delta with a Bluetooth address of 00:16:53:00:00:00, then the two lines of java code should read:
Thank you for your feedback.
In my next posts, I’ll show you how to change the NXT’s map, and how to build the robot in Lego.
In the ConnectPanel.java file, you need to change these two lines of code:
private static final String[] _robotNames = {"MONTE", "Wayfinder"};
private static final String[] _robotAddresses = {"00:16:53:00:57:37","00:16:53:08:82:3a"};
For example, if your NXT is called Delta with a Bluetooth address of 00:16:53:00:00:00, then the two lines of java code should read:
private static final String[] _robotNames = {"Delta"};
private static final String[] _robotAddresses = {"00:16:53:00:00:00"};
Thank you for your feedback.
In my next posts, I’ll show you how to change the NXT’s map, and how to build the robot in Lego.
Monday, August 9, 2010
Sunday, August 8, 2010
Download My Code
You can download my full project code here.
A tutorial video will become available once it's uploaded to YouTube.
Let me know what you think of my project.
A tutorial video will become available once it's uploaded to YouTube.
Let me know what you think of my project.
Tuesday, August 3, 2010
Finding a New Place to Post my Code
I know that some of you have been sending me emails requesting my project code. I am currently looking for a place where the code could be hosted, ideally for free. Unfortunately, apart for images, this blogging service does not permit the posting of documents.
Once I figure out where I can post my project code, I'll let everyone know.
Best regards,
Once I figure out where I can post my project code, I'll let everyone know.
Best regards,
Saturday, July 31, 2010
NXT Bluetooth Tutorial
This blog is the first of many as a tutorial on using the NXT with Bluetooth. First, I’ll speak to the issue of programming the robot because it’s the easiest to understand. The following program is intended to be run on the NXT. This code will not run on your PC.
The steps for your NXT are quite simple
1. Declare all of the class’s instance variables.
2. Display a message on the NXT’s LCD display that the NXT is waiting for a connection. I also like the NXT to sound two beeps in case the NXT is not near enough to read the LCD.
3. Make a blocking call to wait for a Bluetooth connection from your PC. I'll explain in future blogs how to make the PC initiate the Bluetooth connection.
4. Once the connection is made, set up the input and output streams. I also like the NXT to sound a tune so that I know that the connection is ready.
5. Next, send the NXT into a while loop controlled by a Boolean flag. The stuff inside the while loop is what you want the NXT to do.
6. When your PC signals the NXT that it is through with the Bluetooth connection, the NXT should set the Boolean flag mentioned in step 5 to false. Consequently, the while loop will cease.
7. Close the input and output buffers to close the Bluetooth connection.
Step 1: Declare all of the class’s instance variables
import lejos.nxt.*;
import lejos.nxt.comm.*;
import lejos.robotics.navigation.*;
import java.io.*;
public class Robot {
public static void main(String [] args) throws Exception
{
int[] command = new int[3];
int[] reply = new int[8];
boolean keepItRunning = true;
String connected = "Connected";
String waiting = "Waiting...";
String closing = "Closing...";
DataInputStream dis = null;
DataOutputStream dos = null;
BTConnection btc = null;
UltrasonicSensor sonic = new UltrasonicSensor(SensorPort.S1);
Pilot piloting = new TachoPilot(56.0f, 121.0f, Motor.C, Motor.A);
The two integer arrays are used to hold the commands sent by the PC to the NXT, and the reply is used to hold the NXT's reply to the command.
The Boolean flag is used to indicate if the while loop is to keep looping.
The strings are used to display status messages on the LCD screen.
The streams are used to facilitate communication between the PC and the NXT.
The ultrasonic sensor and pilot objects are used within the while loop to control the NXT.
Step 2: Display a Message and Sound two Beeps
LCD.drawString(waiting,0,0);
LCD.refresh();
Sound.twoBeeps();
These simple commands put the words “Waiting…” on the NXT’s LCD and sounds two beeps.
Step 3: Wait for a Bluetooth Connection
btc = Bluetooth.waitForConnection();
Remember that this is a blocking method call. The NXT will not go beyond this step until it makes a Bluetooth connection. I’ll explain in future blog posts how the PC initiates the Bluetooth connection. If you try to run this program on your NXT, it will stop at this point and go no further.
Step 4: Set up the Streams
dis = btc.openDataInputStream();
dos = btc.openDataOutputStream();
Sound.beepSequenceUp();
With the Bluetooth connection established the streams can be opened. I make the NXT play a tune as an audible reminder that a Bluetooth connection has been successfully made.
Steps 5 and 6: Go into a while loop
while (keepItRunning){
// put your stuff here including code to change the Boolean
// flag to false once the PC signals to end the connection
}
Step 7: Close the Streams and the Bluetooth Connection
dis.close();
dos.close();
Thread.sleep(100); // wait for data to drain
LCD.clear();
LCD.drawString(closing,0,0);
LCD.refresh();
btc.close();
LCD.clear();
} // end of main
} // end of class Robot
Closing the streams and the Bluetooth connection is very simple. I also have status messages displayed on the NXT’s LCD.
In my next blog entry I’ll elaborate on Steps 5 and 6; that is, the “stuff” you want your NXT to do.
Go questions? Post a comment. I’ll reply.
The steps for your NXT are quite simple
1. Declare all of the class’s instance variables.
2. Display a message on the NXT’s LCD display that the NXT is waiting for a connection. I also like the NXT to sound two beeps in case the NXT is not near enough to read the LCD.
3. Make a blocking call to wait for a Bluetooth connection from your PC. I'll explain in future blogs how to make the PC initiate the Bluetooth connection.
4. Once the connection is made, set up the input and output streams. I also like the NXT to sound a tune so that I know that the connection is ready.
5. Next, send the NXT into a while loop controlled by a Boolean flag. The stuff inside the while loop is what you want the NXT to do.
6. When your PC signals the NXT that it is through with the Bluetooth connection, the NXT should set the Boolean flag mentioned in step 5 to false. Consequently, the while loop will cease.
7. Close the input and output buffers to close the Bluetooth connection.
Step 1: Declare all of the class’s instance variables
import lejos.nxt.*;
import lejos.nxt.comm.*;
import lejos.robotics.navigation.*;
import java.io.*;
public class Robot {
public static void main(String [] args) throws Exception
{
int[] command = new int[3];
int[] reply = new int[8];
boolean keepItRunning = true;
String connected = "Connected";
String waiting = "Waiting...";
String closing = "Closing...";
DataInputStream dis = null;
DataOutputStream dos = null;
BTConnection btc = null;
UltrasonicSensor sonic = new UltrasonicSensor(SensorPort.S1);
Pilot piloting = new TachoPilot(56.0f, 121.0f, Motor.C, Motor.A);
The two integer arrays are used to hold the commands sent by the PC to the NXT, and the reply is used to hold the NXT's reply to the command.
The Boolean flag is used to indicate if the while loop is to keep looping.
The strings are used to display status messages on the LCD screen.
The streams are used to facilitate communication between the PC and the NXT.
The ultrasonic sensor and pilot objects are used within the while loop to control the NXT.
Step 2: Display a Message and Sound two Beeps
LCD.drawString(waiting,0,0);
LCD.refresh();
Sound.twoBeeps();
These simple commands put the words “Waiting…” on the NXT’s LCD and sounds two beeps.
Step 3: Wait for a Bluetooth Connection
btc = Bluetooth.waitForConnection();
Remember that this is a blocking method call. The NXT will not go beyond this step until it makes a Bluetooth connection. I’ll explain in future blog posts how the PC initiates the Bluetooth connection. If you try to run this program on your NXT, it will stop at this point and go no further.
Step 4: Set up the Streams
dis = btc.openDataInputStream();
dos = btc.openDataOutputStream();
Sound.beepSequenceUp();
With the Bluetooth connection established the streams can be opened. I make the NXT play a tune as an audible reminder that a Bluetooth connection has been successfully made.
Steps 5 and 6: Go into a while loop
while (keepItRunning){
// put your stuff here including code to change the Boolean
// flag to false once the PC signals to end the connection
}
Step 7: Close the Streams and the Bluetooth Connection
dis.close();
dos.close();
Thread.sleep(100); // wait for data to drain
LCD.clear();
LCD.drawString(closing,0,0);
LCD.refresh();
btc.close();
LCD.clear();
} // end of main
} // end of class Robot
Closing the streams and the Bluetooth connection is very simple. I also have status messages displayed on the NXT’s LCD.
In my next blog entry I’ll elaborate on Steps 5 and 6; that is, the “stuff” you want your NXT to do.
Go questions? Post a comment. I’ll reply.
Monday, July 26, 2010
Still Fixing my Code
This weekend, I was fixing up my code for my Monte Carlo localization project. Unfortunately, the Lejos API was changed so much so that much of the functionality was broken.
While it didn't take long to change the code over, now I have to test it to ensure that the new libraries that I'm accessing produce similar results.
I'll probably get back to more fixing of my code this weekend coming up.
While it didn't take long to change the code over, now I have to test it to ensure that the new libraries that I'm accessing produce similar results.
I'll probably get back to more fixing of my code this weekend coming up.
Tuesday, July 20, 2010
API Changes have broken my code
Since I've been away, changes have been made to the Lejos API. Unfortunately, the removal of some classes, and the changes in other classes have broken my code. This code used Bluetooth, and I wanted to illustrate the use of my code to you.
In my next blog entry, I'll demonstrate why changing a public interface in an API can adversely affect users.
In my next blog entry, I'll demonstrate why changing a public interface in an API can adversely affect users.
Sunday, July 18, 2010
Back in Business
After a long time away from blogging about the NXT and LEJOS programming in the Java programming language, I'm back.
I'm a software developer at Research in Motion, the makers of the BlackBerry smartphone.
My major interest with the NXT is using Bluetooth to use the PC and the NXT together. The PC is dedicated to do complex calculations, while the NXT is used as, essentially, a mobile sensor platform. I am particularly interested in the Monte Carlo localization.
Go questions. Send me a reply to this post.
Stay tuned for new blog posts.
I'm a software developer at Research in Motion, the makers of the BlackBerry smartphone.
My major interest with the NXT is using Bluetooth to use the PC and the NXT together. The PC is dedicated to do complex calculations, while the NXT is used as, essentially, a mobile sensor platform. I am particularly interested in the Monte Carlo localization.
Go questions. Send me a reply to this post.
Stay tuned for new blog posts.
Subscribe to:
Comments (Atom)