View unanswered posts | View active topics It is currently Fri Jul 25, 2014 8:28 am






Reply to topic  [ 2 posts ] 
how to read BT data from mobile phone ? 
Author Message
Rookie

Joined: Sun Mar 22, 2009 5:19 am
Posts: 6
Post how to read BT data from mobile phone ?
Hallo,

I found a few java phone applications that were designed to steer NXT robot, for example:

NXT Remote Control: http://demin.ws/nxt/bluetooth/
NXT-Symbian: http://sourceforge.net/projects/nxt-symbian/files/

These applications properly connect to NXT but unfortunately, they don't steer NXT properly from my Nokia E51.

My idea is to read messages that mentioned applications send by BT and based on it - to steer my NXT.
The question is: how to read the message that is being sent from these java applets ?

best regards,
Maciej


Tue Jan 17, 2012 4:12 pm
Profile
Rookie

Joined: Sun Mar 22, 2009 5:19 am
Posts: 6
Post Re: how to read BT data from mobile phone ?
I have found solution:
the full code is:

Code:
#pragma config(Sensor, S1,     accel,               sensorI2CCustom)
#pragma config(Sensor, S2,     Gyro,                sensorI2CHiTechnicGyro)
#pragma config(Sensor, S3,     sonar,               sensorSONAR)
#pragma config(Motor,  motorB,          motorB,        tmotorNormal, PIDControl, encoder)
#pragma config(Motor,  motorC,          motorC,        tmotorNormal, PIDControl, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

byte valueReceived[8]; // 8 bytes are being read

// NXT Remote Control java applet (www: demin.ws/nxt/bluetooth/) installed on mobile sends by BT:
// string FORWARD if 2 key is pressed; valueReceived[1]==79 states for "O"
// string BACKWARD if 8 key is pressed; valueReceived[1]==65 states for "A"
// string LEFT if 4 key is pressed; valueReceived[1]==69 states for "E"
// string RIGHT if 6 key is pressed; valueReceived[1]==73 states for "I"
// string STOP if 5 key is pressed; valueReceived[1]==84 states for "T"

task main()
{
while(true)
   {
   cCmdMessageRead(valueReceived, 8, 1);
   if ((valueReceived[1]==49) || (valueReceived[1]==79)) //Forward;79
      {
       motor[motorB]=20;
       motor[motorC]=20;
      }
   if ((valueReceived[1]==50) || (valueReceived[1]==65)) //Backward;65
      {
       motor[motorB]=-10;
       motor[motorC]=-10;
      }

   if ((valueReceived[1]==51) || (valueReceived[1]==69)) //Left;69
      {
       motor[motorB]=20;
       motor[motorC]=-20;
      }

   if ((valueReceived[1]==52) || (valueReceived[1]==73)) //Right;73
      {
       motor[motorB]=-20;
       motor[motorC]=20;
      }

   if ((valueReceived[1]==53) || (valueReceived[1]==84)) //Stop;84
      {
       motor[motorB]=0;
       motor[motorC]=0;
      }
   // nxtDisplayTextLine(2, valueReceived[1]);
   }
   wait1Msec(5);
}


Wed Jan 18, 2012 5:58 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.