Show Posts
Pages: 1 ... 10 11 [12] 13 14 ... 26
166  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: August 26, 2013, 02:24:40 pm
Thanks CHulla

Good luck for this new project  smiley-wink
167  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: August 25, 2013, 03:18:11 pm
I just received this message via PM:
Quote
Hey kas!

First off all, I would like to say that you have done a great job in creating the app to control robots. I have made mine, which is a car, and glad say that it works well.

I built it using the 2.5 ~ 2.6 version, in which the version still had the (2, 60, 60, 3) format. My phone automatically updated to the 3.0 version, and unfortunately, the robot is not working. As I understand, the actual sent data has changed?

Anyway, going to the point, I would like to request links to the previous versions of the application, just so to test my older code. Is that possible?

Thanks in advance.

-Gin319

The Google Play auto update feature is a real pain smiley-zipper
For those in the same situation, please let me have your email via PM,
I will send you the previous version

Sorry for the trouble
168  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: August 25, 2013, 03:17:00 am
Quote
Of course now I can divide the range -180 to +180 by 2 in arduino program, but now is new problem: on small resolution it is imposible to achieve this resolution of joystick movement, and value jumps every 2-3 points.. My suggestion is to give range (-90 to 90) instead of 100-100 or 180-180,
I am not sure that reducing Data Range from -180/180 to -90/90 will help increasing servo resolution
Should you want it, let me have your email via PM, I will send you a special build with -90/90 data range for test


Quote
"reset button" can be used for example to make an cannon ...
But now, if there is two-way communication with button status I think this can be done with existing keys and program on arduino.
You got the point, button behavior is define within the Arduino sketch:
 - Latch button (on-off switch):
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;
    ...............
}

 - Momentary button (reset button):
Code:
void setLED(int LEDstatus)  {
  switch (LEDstatus) {
    case '1':
      Serial.println("Button_1: momentary ON");
      // Fire...
      break;
    case '2':
      // no code here (drop Button1 off case)    
      break;
    .......
}

169  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: August 23, 2013, 10:31:55 am
Android Bluetooth joystick V3.0 is now available on Google Play

I have added servo's -180/180 data range as per starybryg suggestion
To avoid transmitting negative number, data offset has been increased to 200

Code from reply #74
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
  joyY = joyY - 110;               // to avoid negative numbers
  
  Serial.print("Joystick data:  ");
  Serial.print(joyX);  
  Serial.print(", ");  
  Serial.println(joyY);
 
  // Your code here ...
}

should be modified as follow:
Code:
void setJoystick_Int(byte data[5])    {
  // Demo
.......
  joyX = joyX - 200;               // Transmission offset = 200
  joyY = joyY - 200;               // to avoid negative numbers
.......  

  // Your code here ...
}

Should you find any glitch, please let me know
I will also appreciate any feed back, especially for screen layout

Enjoy  smiley-wink
170  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
171  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
172  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
173  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
174  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...
175  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
176  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
177  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
178  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

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


Joystick Bluetooth Commander Version 2.5 here
180  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
Pages: 1 ... 10 11 [12] 13 14 ... 26