Show Posts
Pages: 1 ... 10 11 [12] 13 14 ... 26
166  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: August 22, 2013, 03:46:02 pm
Quote
1. Please add to configuration (Options -> Advanced Options.. -> Data Range) the ability to set a higher resolution - 128 or 180. Servos have 180degree and we lose fluidity of movement: currently every change on joystick is 1,8 degree in servo, but servo can move every 1 degree.
Makes sense, I will add -180 +180 Data range in V3.0 (to be published this week end)

Quote
2. If you made this communication two-way with checking button status, please think about adding 2 (or more) "reset" buttons (not "on-off").
Not sure I understand, please elaborate

Quote
3. Autoconnect function will be nice!!:)
AutoConnect is now ready

Quote
4. Can you share developer version of the application? Or better yet- the source code? I do not I program for android, but certainly a lot of people will be grateful.
Will definitely share source code
167  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: August 21, 2013, 11:49:55 am
Quote
Thank for releasing this fantastic app!
My first steps with Arduino, and with bluetooth were smoother because of your app!!
Thanks for your feedback  smiley-cool


Quote
Is there a recommended post to learn how to control the joytick with servos?
I just posted the Bluetooth robotic dancer source code here

EDIT: Link is now OK
168  Topics / Robotics / Re: Bluetooth robotic dancer on: August 21, 2013, 11:37:01 am
Hi Rosamunda

Here is the Arduino side code:
Code:
// Andro_Pan&Tilt      V2.6
// Arduino test sketch for Joystick BT commander
// Controls two servo motors

// V2.6 can receive both Byte (Joystick BT commander V2.5)& Integer data (V3.0)
// V2.0: removed SoftwareSerial

//  Arduino pin #0  to  TX Bluetooth module

#include <Servo.h>

#define    DEBUG          false

#define    ledPin         13              // LED pin
#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            // horizontal move limitation
#define    ZERO_Y         60

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);  
  pinMode(ledPin, OUTPUT);
  if(DEBUG)  Serial.println("AndroZinZin V2.5");
}

void loop() {
   if(Serial.available())  {            // received from smartphone
    delay(5);
    cmd[0] =  Serial.read();  
//    if(DEBUG)  Serial.println(cmd[0]);   // ** DEBUG **
    if(cmd[0] == STX)  {  
      i=1;      
      while(Serial.available() && ((cmd[i]=Serial.read()) != ETX)) {
        if(i>5)  break;
//        if(DEBUG)    {Serial.print(i); Serial.print(": "); Serial.println(cmd[i]);}  // ** DEBUG **
        i++;
      }
    }
    if(i==2)    setLED(cmd[1]);
    if(i==3)    setPosition_Byte(cmd[1], cmd[2]);  
    if(i==5)    setPosition_Int(cmd[1]*128+cmd[2], cmd[3]*128+cmd[4]);  
  }
  delay(5);
}

void setLED(int LEDstatus)  {
  switch (LEDstatus) {
    case '1':
      Serial.println("Button_1: ON");
      // your code...      
      break;
    case '2':
      Serial.println("Button_1: OFF");
      // your code...      
      break;
    case '3':
      Serial.println("Button_2: ON");
      // your code...      
      break;
    case '4':
      Serial.println("Button_2: OFF");
      // your code...      
      break;
    case '5':
      Serial.println("Button_3: ON");
      // your code...      
      break;
    case '6':
      Serial.println("Button_3: OFF");
      // your code...      
      break;
    case '7':
      Serial.println("Button_4: ON");
      // your code...      
      break;
    case '8':
      Serial.println("Button_4: OFF");
      // your code...      
      break;
  }
}

void setPosition_Byte(byte posX, byte posY)    {    // Joystick BT commander V2.5
  posX = map(posX, 10, 110, 180, 0);
  posY = map(posY, 10, 110, 0, 180);
  posY+=ZERO_Y;
  posY = constrain(posY, MIN_Y, MAX_Y);
  if(DEBUG)  { Serial.print("(Byte) ");  Serial.print(posX);  Serial.print(", ");  Serial.println(posY); } // ** DEBUG **
  myservoX.write(posX);
  myservoY.write(posY);
}

void setPosition_Int(int posX, int posY)    {        // Joystick BT commander V3.0
  posX = map(posX, 10, 210, 180, 0);
  posY = map(posY, 10, 210, 0, 180);
  posY+=ZERO_Y;
  posY = constrain(posY, MIN_Y, MAX_Y);
  if(DEBUG)  { Serial.print("(Int) ");  Serial.print(posX);  Serial.print(", ");  Serial.println(posY); } // ** DEBUG **
  myservoX.write(posX);
  myservoY.write(posY);
}

Let me know the outcome in the Project main thread

Enjoy
169  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: August 20, 2013, 03:31:39 pm
Quote
its works, perfect! Great, thanks

Thanks!  smiley-wink
170  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: August 18, 2013, 02:13:21 am
Hi guys

Sorry for the delay
Everything is ready, except the autoconnect feature

Stay tuned...
171  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: August 11, 2013, 09:47:13 am
Quote
Sound amazing! Bluetooth name Linvor what possible use?
Not sure I understand your question  smiley-roll
Joystick Bluetooth Commander turns a smartphone/tablet into a remote controller
for home automation or robotic applications
This Android application is available on Google Play

BTW, the Arduino demo sketch is now attached to previous post
172  Using Arduino / Networking, Protocols, and Devices / ** Joystick Bluetooth Commander Version 3.0 ** on: August 10, 2013, 02:21:25 pm
 ** Major Upgrade **

Change Log
Full blown two way Bluetooth communication with the associated microcontroller
Arduino sends back a button status Byte and a user defined data Byte to be displayed
on the phone/tablet screen (Bot battery level is a nice candidate)
Device user defined Data textbox can be renamed and/or hidden if unused
Selectable -50/+50 or -100/+100 output range Option
** EDIT: added -180/+180 output range for servo motors **
Auto-connect at start up Option

Communication protocol
Android device data transmission
Joystick data is now transmitted as an integer = 2 Bytes (Most Significant Byte + Less Significant Byte)
<STX  MSB-X  LSB-X  MSB-Y  LSB-Y  ETX>

Code modification:
Code:
void loop() {
...
else if(i==5)    setJoystick_Int(cmd);  // 6 Bytes
...
}


Integer data is then assembled as follow:
Code:
void setJoystick_Int(byte data[5])    {
  // Demo
  int joyX = (data[1]<<7) + data[2];
  int joyY = (data[3]<<7) + data[4];
  joyX = joyX - 110;               // Transmission offset = 110   XXXXX
  joyY = joyY - 110;               // to avoid negative numbers   XXXXX
  
  Serial.print("Joystick data:  ");
  Serial.print(joyX);  
  Serial.print(", ");  
  Serial.println(joyY);
 
  // Your code here ...
}

** EDIT **     please see reply #84
  joyX = joyX - 200;               // Transmission offset = 200
  joyY = joyY - 200;               // to avoid negative numbers


Arduino data transmission:
Arduino sends back buttonStatus and dataByte
<STX  buttonStatus  dataByte  ETX>
(see  bitwise operators)

Code:
void setLED(int LEDstatus)  {
  switch (LEDstatus) {
    case '1':
      buttonStatus |= B0001;    // Button_1: ON
      Serial.println("Button_1: ON");
      // your code...      
      break;
    case '2':
      buttonStatus &= B1110;    // Button_1: OFF
      Serial.println("Button_1: OFF");
      // your code...      
      break;
    case '3':
      buttonStatus |= B0010;    // Button_2: ON
      Serial.println("Button_2: ON");
      // your code...      
      break;
    case '4':
      buttonStatus &= B1101;    // Button_2: OFF
      Serial.println("Button_2: OFF");
      // your code...      
      break;
    case '5':
      buttonStatus |= B0100;     // Button_3: ON
      Serial.println("Button_3: ON");
      // your code...      
      break;
    case '6':
      buttonStatus &= B1011;     // Button_3: OFF
      Serial.println("Button_3: OFF");
      // your code...      
      break;
    case '7':
      buttonStatus |= B1000;     // Button_4: ON
      Serial.println("Button_4: ON");
      // your code...      
      break;
    case '8':
      buttonStatus &= B0111;    // Button_4: OFF
      Serial.println("Button_4: OFF");
      // your code...      
      break;
  }
  sendData(buttonStatus, dataByte);
}

Advanced hint:
Button status can be monitored at a deeper level by directly manipulating and transmitting Arduino internal ports Byte (see Example Program)

Choose DataByte to taste:

Code:
byte GetdataByte()  {
  // Demo
  static byte i=0;
  i +=5;
  if(i >100)    i = 0;
  return i;  

  // Your code ...
}


Button status is feeded back by Arduino to the Android device
on a timed basis (every 'interval' milliseconds), and each time a button is pressed:
Code:
void loop() {
  if(mySerial.available())  {            // received from smartphone
    ...  
  }  else  {
    unsigned long currentMillis = millis();
    if(currentMillis - previousMillis > interval) {
      dataByte = GetdataByte();
      sendData(buttonStatus, dataByte);         // <<<<<
      previousMillis = currentMillis;  
    }
  }
  ...
}

Code:
void setLED(int LEDstatus)  {
  switch (LEDstatus) {
  ...
  }
  sendData(buttonStatus, dataByte);         // <<<<<
}

Code:
void sendData(byte button, byte data)    {
  mySerial.write(STX);
  mySerial.write((button<<2)+4);
  mySerial.write(data+4);           // +4: avoid 0x2 & 0x3
  mySerial.write(ETX);
}
button status Byte is left shifted to avoid transmitting 0x02 and 0x03 (STX, ETX) values


As already stated, make sure your BT communication is set to 57600 BPS


The full Arduino sketch will be available shortly for download at the bottom of this post

The  Joystick Bluetooth Commander Version 3.0 is ready and debugged, I will upload it at Google Play as soon as user tests
are finished


Quote
Quote
BTW, the Galaxy phone guy [non-techie] was totally amazed how

he could suddenly use his Android phone to control the world, ;-),
I had this very same feeling smiley-cool, this is the reason I decided to share

I believe I did my duty  smiley-wink
According to Google Play, Joystick Bluetooth Commander is now in the 500/1000 downloads ball park  smiley-cool
I spent an interesting month  smiley-roll-blue smiley-roll-blue smiley-roll-blue developing the application, but it's now time to move to other projects.

Thanks again for your interest and suggestions  smiley

Edit:
Arduino sketch attached

Edit2:
Updated demo Arduino sketch at reply #90
173  Using Arduino / Networking, Protocols, and Devices / Re: How to get the JY-MCU bt board to work on: August 04, 2013, 10:36:06 am
Upload this sketch
Code:
void setup()  {
  Serial.begin(230400);
  delay(1000);
  Serial.write("AT+BAUD4");           // 9600 BPS
}

void loop() { }
Connect BT card RX to Pin #1
Reset Arduino
174  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: August 03, 2013, 11:19:36 am
Quote
Thank you KAS.  I really appreciated your response and modifying your app.  I did have to make some changes to my code to deal with unavailable bluetooth data but now it is working wonderfully.  This is an excellent app that works as designed, is well laid out, and has many options and customizations to make it easy to use.
 smiley-red smiley-red smiley-red


Quote
I've configure button one to engage autonomous mode (just got the three sensor ultrasonic array debugged) and to change the motor PWM (speed) for carpet vs. tile
Still a small glitch: the buttons state synchronization can be lost on communication problems or simple Arduino reset
To be a serious control application, Android BT Commander needs two way communication channel and get Arduino acknowledgments to buttons change requests (see Reply #36)
I am working on V3.0 smiley-wink


Please post a photo/video of your new toy   smiley-razz

175  Topics / Robotics / Re: Bluetooth robotic dancer on: August 03, 2013, 01:02:17 am


Joystick Bluetooth Commander Version 2.5 here
176  Using Arduino / LEDs and Multiplexing / Re: LED control via Android smartphone on: August 03, 2013, 12:58:03 am


Joystick Bluetooth Commander Version 2.5 here
177  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: August 01, 2013, 04:07:50 am
Done

@arRaindog:
Make sure to adjust timeout count to the lowest frequency compatible with your Dead Man strategy
178  Using Arduino / Networking, Protocols, and Devices / ** Version 2.5 ** on: July 30, 2013, 06:43:24 am
I just received a new Galaxy Tab3 8" tablet smiley-cool

The application didn't run well on this specific machine smiley-sad-blue
 - toggle buttons didn't show the green LEDs as per reply #47
 - erratic joystick movements
 - screen layout was far from optimal on large tablets

Version 2.5 change log:
  layout adapts to device screen size
  better looking buttons
  fixed joystick bug (for the Android nerds: "nested weight")
  removed "Data Format" option (useless)
  buttons/joystick data collision management



@arRaindog:
Go to Option/Advanced Option/Timeout count
set to "Continually", should now work as expected

@_SBC_:
the display on your Samsung galaxy Y should now be OK with this new version
please confirm

I will test the application and upload it here, within 24 hours
Get it directly from your device with Google Play

I definitely can't purchase every Android devices to check layout
Please let me have a feedback, possibly with screenshot
179  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: July 29, 2013, 01:07:55 am
Quote
As a fail safe I designed the code so the robot stops in the absence of a control signal
Got the point, make sense  smiley-roll-blue
I will create the option this week

180  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: July 29, 2013, 12:52:46 am
Quote
Thank you for the wonderful app.
...
Again thank you for your hard work on this app.
Thanks for the nice comment and welcome to the Forum  smiley


Quote
I've searched through the options but don't see anything to keep the app transmitting while the joystick is held stationary.  Is this an artifact of my android platform, or is this a design element?
To save bandwidth, the application only send data if the joystick position is changed
This is by design
Pseudo code:
Code:
if data <> dataAnt
  sendData()
  dataAnt = data
endIf

See if you can modify your bot code,
it should not need a constant flow of data to work
Otherwise let me know, I will then create a new option
Pages: 1 ... 10 11 [12] 13 14 ... 26