import lejos.nxt.Sound; import lejos.nxt.*; import lejos.nxt.comm.*; //import lejos.robotics.navigation.Pilot; import lejos.robotics.navigation.TachoPilot; //import lejos.nxt.Sound.*; //import icommand.nxt.comm.NXTCommand; import java.io.*; //import icommand.nxt.*; //import icommand.nxt.Motor; import lejos.nxt.SensorPort; import lejos.nxt.SensorPortListener; import lejos.nxt.TouchSensor; /** * Receive data from another NXT, a PC, a phone, * or another bluetooth device. * * Waits for a connection, receives an int and returns * its negative as a reply, 100 times, and then closes * the connection, and waits for a new one. * * @author Lawrie Griffiths * */ public class BTreceive{ public static void main(String [] args) throws Exception { String connected = "Connected"; String waiting = "Waiting..."; String closing = "Closing..."; TachoPilot robot = new TachoPilot(5.6F,16F,Motor.B,Motor.C);//Your Motor information robot.setMoveSpeed(5); TouchSensor touch1 = new TouchSensor(SensorPort.S1); TouchSensor touch2 = new TouchSensor(SensorPort.S4); while (true) { LCD.clear(); LCD.drawString(waiting,0,0); LCD.refresh(); BTConnection btc = Bluetooth.waitForConnection(); LCD.clear(); LCD.drawString(connected,0,0); LCD.refresh(); DataInputStream dis = btc.openDataInputStream(); DataOutputStream dos = btc.openDataOutputStream(); int state = 0; while(true) { String temp=""; int flag=0; byte []b = new byte[100]; int read_bytes = dis.read(b); byte []b2 = new byte[read_bytes]; for(int i =0;i