Show Posts
Pages: 1 ... 10 11 [12] 13 14 ... 27
166  Topics / Robotics / Re: Bluetooth robotic dancer on: November 02, 2013, 04:51:15 am
This is the revised sketch, compatible with Joystick Bluetooth Commander V3.X
(modified communication protocol)

Code:
// Andro_Pan&Tilt      V3.1
// Arduino demo sketch for Joystick BT commander V3.X
// Controls two servo motors

// V3.0: Android BT Commander V3.X compatible, no button data management
// V2.5 can receive both Byte & Integer data
// V2.0: removed SoftwareSerial

// Android BT Commander settings:
// Options/Options for advanced users/Data Range        >>>  -180 to +180
// Options/Options for advanced users/Refresh interval  >>>  25ms

//  Arduino pin #0 to TX BlueTooth module
// BT TX to be disconnected from D0 during sketch upload

#include <Servo.h>

boolean    DEBUG =         true;

#define    pinServo_X     9
#define    pinServo_Y     10
#define    STX            0x02
#define    ETX            0x03
#define    MIN_Y          45             // vertical move limitation
#define    MAX_Y          180
#define    ZERO_Y         60             // vertical offset

int i=0;
byte cmd[6] = {0, 0, 0, 0, 0, 0};
Servo myservoX;                         // create servo object
Servo myservoY;

void setup()  {
  Serial.begin(57600);
  myservoX.attach(pinServo_X);  
  myservoY.attach(pinServo_Y);  
  if(DEBUG)  Serial.println("Stepper demo for Android BT Commander V3.X");
}

void loop() {
  if(Serial.available())  {                   // data received from smartphone
    delay(5);
    cmd[0] =  Serial.read();  
    if(cmd[0] == STX)  {  
      i=1;      
      while(Serial.available())  {
        cmd[i] = Serial.read();
        if(cmd[i] == ETX)  {
          if(i==2 && cmd[1]>48)                break;    // Button data
          if(i==5 && cmd[1]<3 && cmd[3]<3)     break;    // Joystick data
        }
        if(i>5)   break;
        i++;
      }
      if     (i==2)   Serial.println("Button data not implemented");             // 3 Bytes
      else if(i==5)   setServoPosition(cmd);                                     // 5 Bytes
      else            Serial.println("Communication error");
    }
  }
  delay(5);
}

void setServoPosition(byte data[5])    {
  int joyX = (data[1]<<7) + data[2];
  int joyY = (data[3]<<7) + data[4];
  joyX = joyX - 200;                         // Offset to avoid
  joyY = joyY - 200;                         // transmitting negative numbers
  
  joyX = map(joyX, -180, 180, 180, 0);      // (-180/+180 JBC range)
  joyY = map(joyY, -180, 180, 0, 180);

  joyY+=ZERO_Y;
  joyY = constrain(joyY, MIN_Y, MAX_Y);
  myservoX.write(joyX);
  myservoY.write(joyY);
  if(DEBUG)  {Serial.print(joyX); Serial.print(", "); Serial.println(joyY);}
}

Please post technical questions in the main thread
167  International / Français / Re: Bluetooth JY-MCU on: November 02, 2013, 04:21:06 am
Bonjour,

Voici un lien vers une App qui crée un joystick virtuel sur l'écran d'une tablette ou d'un smartphone Android
Coté Arduino, la meme carte JY-MCU est utilisée

http://forum.arduino.cc//index.php?topic=173246.0

Je suis dispo pour toutes infos complémentaires
168  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: November 02, 2013, 02:40:22 am
Hi o_lampe

Quote
BTW, if you get bored one time, pleeease write a version for stepper
motors as well  smiley-wink

What is your specific application that make you choose steppers over servo's ??


Quote
does anybody know the AT-command to change the PIN-code for the BT
module?

Assuming you have a JY-MCU or compatible board, see here and scroll down to mid page:

AT+PINxxxx  Sets the pairing password of the device
Any 4 digit number can be used, the default pincode is 1234
Response: OKsetPIN


Quote
It seems, that soft_serial only works up to 57600 BAUD. My BT-module was
setup to 115200 BAUD, that's why it didn't work

Using hardware serial, mega2560 board should be OK @115200 baud (and higher with
a third party Serial Monitor)
169  Community / Bar Sport / Re: How to handle collisions for a flying robot - video on: November 01, 2013, 08:39:58 am
Brilliant   smiley-eek smiley-eek smiley-eek
170  Topics / Device Hacking / Re: This is what we're missing from the Arduino range! on: November 01, 2013, 08:28:55 am
Raise funds through kickstarter.com and create your own company to market the product worldwide
Please rush before somebody steal this great idea   smiley-wink smiley-wink smiley-wink
171  Community / Exhibition / Gallery / Re: Cloud Lamp showing a storm on: November 01, 2013, 08:09:57 am
Nice and original project, thanks for sharing
172  Topics / Science and Measurement / Re: 9 Degree of Freedom on: November 01, 2013, 01:54:18 am
Have a look at Invensense MPU-9150
http://www.ebay.com/itm/9DOF-MPU-9150-3-Axis-Gyroscope-Accelerometer-magnetic-field-replace-MPU-6050-/310670112244?pt=LH_DefaultDomain_0&hash=item485561b5f4
(Gyro+Acc+Mag on a single chip)
173  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: October 29, 2013, 05:05:31 am
Quote
Thank you for sharing this awesome app

Thanks jooheepark,
I appreciate the time you spent for registering and sharing your experience
Matching baud rate is indeed a key point for success (together with RX/TX proper wiring)

@all
please report
 - bugs (if any smiley-wink)
 - requested new features

and...  info's regarding your new Bluetooth RC toy

I personally use this App for controlling my balancing robot, using now the MPU-6050 gyro/acc combo

174  Using Arduino / Networking, Protocols, and Devices / ** Version 3.1 ** on: October 11, 2013, 02:25:54 pm
V 3.1  maintenance version

 - Joystick constraint: box or circle option (as per balaclava07 request)
 - better algorithm for data reception from Arduino
 - various minor fixes

To be uploaded here later today

175  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: September 25, 2013, 01:11:53 am
I just realized that the Arduino sketch is not attached to previous post, sorry guys, here it is
EDIT: You must be logged to see the file  smiley-roll-blue

some functions have been renamed to more meaningfull names

for this demo
 - Button #1:  built in LED control
 - Button #2:  enable Debug mode
 - Button #3:  configured as momentary
 - Button #4:  configured as momentary

EDIT: Please  discard V10.2 and download V10.3 (see reply #129)

176  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: September 13, 2013, 11:46:23 am
With range -100/+100, some joystick positions do interfere with ETX (0x3):

X=59, Y=24  is transmitted as  <2  2  3  1  96  3>
X=47, Y=59  is transmitted as  <2  1  119  2  3  3>

In these two examples, a transmission error is generated as ETX is detected earlier than expected
I have modified the Arduino demo sketch to definitely address this situation

AndroLED V10 is attached to this message
I suggest to use the same decoding algorithm in your own program  

EDIT:
replaced   previousMillis = currentMillis - interval*0.9;  
by            previousMillis = currentMillis - interval*0.5;
to avoid possible racing conditions  

please download again (V10.1)
177  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: September 09, 2013, 08:59:52 am
OK...
This feature will be included, as an option, in V3.1
178  Using Arduino / Networking, Protocols, and Devices / Re: Sending data TO gps on: September 09, 2013, 12:45:32 am
Found the link to the Fastrax NEMA commands, here it is
179  Using Arduino / Networking, Protocols, and Devices / Re: Sending data TO gps on: September 07, 2013, 10:46:27 am
You can talk to your GPS module using NEMA Commands

For my Fastrax UP501 all sentences start with $PMTK
$PMTK251,38400*27<CR><LF>  will set baud rate @38400
$PMTK300,1000,0,0,0,0*1C<CR><LF>   will set fix interval
$PMTK314 ... will select message to be sent (GGL, RMC, GGA...)

Not sure this protocol is valid for your specific GPS module
180  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: September 06, 2013, 01:57:26 pm
Quote
Quote
What about developing the same type of application, but using the android device built in accelerometers
Control would be performed just by tilting the smartphone/tablet.
The joystick would be a "read only" device, reflecting the device inclination.

      This sister application could be called Acc Bluetooth Commander
       Any interest ???

I think that's a great idea.  Or just add an option to the current app to toggle using the accelerometer instead of your finger to control the joystick.

-transfinite

That's another great idea, thanks transfinite
We could call it  "Total BT Commander"   smiley-wink

BTW, any "unexpected behavior" in V3.0 ???
Pages: 1 ... 10 11 [12] 13 14 ... 27