Show Posts
Pages: 1 2 3 [4] 5 6 ... 26
46  Community / Exhibition / Gallery / Re: Android controlled RC tank with on-board Video on: June 04, 2014, 03:41:21 am
This sketch has been updated to AndroTest.ino V1.41

Code:
#define VERSION     "AndroTest V1.41A - @kas2014\ndemo for V4.X  (6 button version)"


// V1.41A Sabertooth version
// V1.3A Sabertooth version
// Demo setup: motor only, no buttons

// Arduino pin#2 to TX BlueTooth module
// Arduino pin#3 to RX BlueTooth module
// make sure your BT board is set @57600 bps
// better remove SoftSerial for PWM based projects

// For Mega 2560:
// remove   #include "SoftwareSerial.h", SoftwareSerial mySerial(2,3);
// search/replace  mySerial  >> Serial1
// pin#18 to RX bluetooth module, pin#19 to TX bluetooth module

#include "SoftwareSerial.h"

#include <Servo.h>                // Sabertooth  XXX
Servo motor_R;                    // Sabertooth  XXX
Servo motor_L;                    // Sabertooth  XXX
#define    PWM_R         5        // Sabertooth  XXX  PWM output
#define    PWM_L         6        // Sabertooth  XXX  PWM output

#define    STX          0x01
#define    ETX          0x00
#define    ledPin       13
#define    SLOW         1000                           // Datafields refresh rate (ms)
#define    FAST         250                            // Datafields refresh rate (ms)

boolean DEBUG = false;

SoftwareSerial mySerial(2,3);                           // BlueTooth module: pin#2=TX pin#3=RX
int i=0;
byte cmd[6] = {0, 0, 0, 0, 0, 0};                       // bytes received
//byte buttonStatus = 0;                                  // first Byte sent to Android device
//long previousMillis = 0;                                // will store last time Buttons status was updated
//boolean setButtonFeedback = false;                      // momentary buttons feedback to Android device
//long sendInterval = SLOW;                               // interval between Buttons status transmission (milliseconds)
//String displayStatus = "xxxx";                          // message to Android device

void setup()  {
  Serial.begin(57600);
  mySerial.begin(57600);                                // 57600 = max value for softserial
  pinMode(ledPin, OUTPUT);     
  Serial.println(VERSION);
  motor_R.attach(PWM_R);             // Sabertooth  XXX
  motor_R.attach(PWM_L);             // Sabertooth  XXX
}

void loop() {
  if(mySerial.available())  {                            // data received from smartphone
    delay(2);                                                              //  <<mod XXXXXXXX
    cmd[0] =  mySerial.read(); 
    if(cmd[0] == STX)  {
      i=1;     
      while(mySerial.available())  {
        delay(1);                                                          //  <<mod XXXXXXXX
        cmd[i] = mySerial.read();
        if(cmd[i]>127 || i>5)                               break;   // Communication error << XXX Mod
        if((cmd[i]==ETX) && ((i==2 && cmd[1]>2) || i==5))   break;   // Button or Joystick data
        i++;
      }
      if     (i==2 && cmd[1]>48 && cmd[1]<68)     getButtonState(cmd[1]);                         // 3 Bytes
      else if(i==5 && cmd[1]<3  && cmd[3]<3 )     getJoystickState(cmd);                          // 6 Bytes
      if(DEBUG)       printDebug(i);
    }
  }
  sendBlueToothData();                                                       //  <<mod XXXXXXXX
}


void getJoystickState(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

  if(!DEBUG)  {
    Serial.print("Joystick position:  ");
    Serial.print(joyX); 
    Serial.print(", "); 
    Serial.println(joyY);
  }
 
// Your code here ...

  joyX = map(joyX, -100, 100, 0, 180);             // Sabertooth  XXX
  joyY = map(joyY, -100, 100, 0, 180);             // Sabertooth  XXX
 
// 180: full forward,  0: full reverse, 90: stop
  motor_R.write(joyX);                             // Sabertooth  XXX
  motor_L.write(joyY);                             // Sabertooth  XXX
}

void getButtonState(int bStatus)  {
  // do nothing
}

void sendBlueToothData()  {
  // do nothing
}

//String getButtonStatusString()  {
//}

//int GetdataInt1()  {              // Data dummy values sent to Android device for demo purpose
//}

//float GetdataFloat2()  {           // Data dummy values sent to Android device for demo purpose
//}

void printDebug(int nByte)  {
  if(nByte ==2)    {   
//    Serial.print("buttonStatus: "); Serial.print(buttonStatus);
//    Serial.print("  bin: "); Serial.println(getButtonStatusString());   
//    Serial.print("Button: < ");
  }
  else if(nByte ==5)  Serial.print("Joystick: < ");
  else                Serial.print("*error*: < ");
  for(int j =0; j<nByte+1; j++) { Serial.print(cmd[j]); Serial.print(" "); }
  Serial.println(">");
}


Quote
When the joystick goes left the bot goes forward, when the joystick goes right the bot goes backward.
The forward and backward movement of the stick does nothing to the bot.
smiley-roll smiley-roll smiley-roll
Left motor should turn Forward/Backward with joystick moving North/South
Right motor should turn Forward/Backward with joystick moving East/West
Double check your cabling and let me know the status
47  Community / Exhibition / Gallery / Re: Android controlled RC tank with on-board Video on: June 02, 2014, 03:15:38 pm
Quote
I really appreciate all your help. Keep up the great work on this fantastic application.
Thanks to you tolisn63, as you are the one who suggested to add Video to Joystick bluetooth Commander
48  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: June 02, 2014, 03:16:41 am
Quote
Hello Kas,

First I would like to say thank you for the great piece of software you have written.  It has made implementing this type of controls into my project SO much easier.

I do have one question for you, but it would probably be better to give you a little background first...

I'm currently developing an autonomous mobile robot platform, with the UI to control it on an Android tablet.  I've developed most of the UI already for my device, and included a button that opens your Joystick BT Commander app directly from within my UI, for when the end user needs to manually control the robot.

However the Joystick BT Commnader app looks nothing like my UI design/theme, most notably you have a dark theme while my UI uses a "light" theme with a white background.

So my question for you is are you planning on implementing any sort of customization in this area into your app in the near future at all?  If not, is there some way that I can change the colors so our software would better compliment eachother?  I know I can go back and redesign my UI to match your app, but for my particular application (outdoors and/or in direct sunlight) a dark theme is a lot harder for the end user to see.

Thanks in advance for any assistance you can provide.  It is greatly appreciated.

Hi joepro
Thanks for the comments
Should be included in V5.0, to be posted within 4 weeks
49  Community / Exhibition / Gallery / Re: Android controlled RC tank with on-board Video on: June 01, 2014, 02:15:51 pm
DHCP Server Setup
Start IP Address     192.168.1.2
End IP Address       192.168.1.254

Alternatively, try unchecking  Enable DHCP server
50  Community / Exhibition / Gallery / Re: Android controlled RC tank with on-board Video on: June 01, 2014, 10:11:11 am
Quote
Also there is a flasing indicator(red-blue) in the mini router
That's good new

Go back to your Mini router web configuration pages
LAN/setup
LAN IP address
change 192.168.100.1  to 192.168.1.1
51  Using Arduino / Networking, Protocols, and Devices / BT card configuration for dummies on: June 01, 2014, 03:39:31 am
Quote
Please show me the way to check and configure my bluetooth card
thanks, Christian

Bluetooth cards come in a many flavors HC-05, HC-06, HC-07, HC-08 ...

I personally own an HC-06


and an a convenient Arduino/HC-05 combo



Configuration methods are quite different according to board type

For 57600 bps setup:
Code:
HC-05:        AT+UART=57600,0,0\r\n        (with linefeed + return)
HC-06:        AT+BAUD7                     (w/o linefeed + return)
The all point is to access the board configuration mode
My HC-05 board has a built in switch + reset button for easy operation (see above)

Arduino member Nick_Pyner has produced a very interesting document, I learned a lot from it
Don't forget to increase Nick's Karma by hitting the green "+" sign below his name

Complete AT command set:
HC-05
HC-06

Further readings here

Finally, I attach two sketches for configuring HC-05 and HC-06 boards


Enjoy the fascinating Bluetooth universe  smiley-wink


@all
Feel free to post your personal experience and additional links

52  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: May 31, 2014, 05:56:25 am
@n3kx
Quote
My problem was in bautrate
Glad it finally works  smiley


Quote
and also you must press 3.rd button to get work .... so you overwrite setbuttonfeedback=false to  setbuttonfeedback=true and it work for my
smiley-roll-blue smiley-roll-blue smiley-roll-blue   setButtonFeedback was created for handling push buttons
This is a flag to send an earlier feed back to Android, for a consistent visual effect
setButtonFeedback is reset to False with each sendBlueToothData() call:
Code:
 if(setButtonFeedback == true)  {                      // allow momentary button visual effect
    previousMillis = currentMillis + 250;  
    setButtonFeedback = false;
  }
This code snippet could be safely omitted (will be removed in next release):

setButtonFeedback is misplaced and should be moved from Button #3 to Button #5 (push button)
I edited accordingly AndroTest V1.4 in response #212

53  Community / Exhibition / Gallery / Re: Android controlled RC tank with on-board Video on: May 31, 2014, 05:52:07 am
@tolisn63
Quote
This just came in. Ho do you go about configuring it to use with the camera and what would the URL be so it can be inserted into the application ?

Connect the camera (ethernet cable)
The router will appear as MIFI-XXXX in your available wireless network listing, along with your home network and your neibourgh's
Connect to MIFI-XXXX default password: 1234567890
To access the router home page, type 192.168.100.1 in your browser

Use your Wanscam Search tool to detect your camera, should be 192.168.1.XX5
Make sure the camera address is static and voilà   smiley-wink

You can access the camera from Total RC Commander using the same settings as for your home router, nothing to change within the App

Did you receive an operator manual with the router ??

54  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: May 30, 2014, 04:58:42 am

For those who still have a Bluetooth card configured @9600bps, please add a one millisecond delay after the second "while(mySerial.available())"

Code:
void loop() {
  if(mySerial.available())  {
    delay(2);
    cmd[0] =  mySerial.read();  
    if(cmd[0] == STX)  {
      i=1;      
      while(mySerial.available())  {
     delay(1);                     //  <<mod     <-------------<<<
        cmd[i] = mySerial.read();
        ...........
 
}
 
This will prevent  while(mySerial.available())  to return before the complete data frame is received
I have modified AndroTest V1.4 to reflect this modification (now Version 1.41)

I only work @57600bps and never bothered checking lower data speeds  smiley-red
Thanks Topicja for bringing this point to my attention

A sweet thought for the Microsoft developers who deal with thousands different hardware configurations and get bashed by users because...  "it doesn't work on MY specific setup"   smiley-wink
55  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: May 29, 2014, 10:39:51 am
@Topicja
Quote
I could recompile V3.1, but it makes much more sense to have your own program fixed and working
Joystick transmission has not been modified and should work, does it??
Please let me have your original Arduino sketch, I will fix it for you
I will send you the modified sketch tomorrow evening
There are too many transmission errors at 9600 bps
Please, in the meantime, configure your BT card at 57600 bps

Are you able to do it by yourself ??
Otherwise, let me have a link to your specific model
56  Using Arduino / Networking, Protocols, and Devices / Joystick bluetooth Commander - older version on: May 29, 2014, 12:29:44 am
@Topicja
Quote
Hi Kas
I really like your excellent android app but after last update i cannot get it to work. I tried to rewrite my program but i don't receive any data. Could you please send me apk file of older version? Version 3.1 was working well for me. My e-mail address is xxxxxxxx@xxx.com

Thank you for your response and your willingness

I could recompile V3.1, but it makes much more sense to have your own program fixed and working
Joystick transmission has not been modified and should work, does it??
Please let me have your original Arduino sketch, I will fix it for you


@all
Should you encounter same difficulties, please contact me via PM

57  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: May 28, 2014, 12:05:44 pm
Quote
This version V4.1 works fine.
Wherever you touch on the yellow spot is returned as coordinate 0,0 (x,y) which is exactly what I was looking for.
No jumpy servos anymore. - Many thanks
Thanks, I will include this feature in V5.0 (pure ASCII protocol)

Quote
1. As information can be sent from Arduino to Android, is it possible to use the Android like a Serial monitor to display this information with rolling values - just like the USB to computer screen. You could give the option to change from Joystick to Monitor to make space on the Android screen.
Android Bluetooth joystick is a small footprint App (78Ko), its only task is to emulate a joystick  smiley-wink
There are very good App for serial monitoring, BlueTerm is one of those

Quote
My Samsung GT-S5570 phone won't recognise the HC-05 so I can't test on mobile phone
Try sending AT command
Code:
AT+CLASS=1
Should work
58  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: May 28, 2014, 02:59:19 am
Quote
I addressed the situation  smiley-wink
Please let me have your email via PM, I will send you V4.1 for testing

Check your mail ...
59  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: May 27, 2014, 12:13:01 pm
@ Bob1943

Quote
Quote
3. When you first touch the yellow joystick dot, it immediately moves to the centre of the touch point. This changes the xy numbers – most noticeable when you touch the edge. (I want to control two servos but don’t want them to move until the joystick is moved intentionally).
Can the touch point be recognised without moving the yellow dot?
I understand your concern, makes sense, let me think about it...

I addressed the situation  smiley-wink
Please let me have your email via PM, I will send you V4.1 for testing
60  Using Arduino / Networking, Protocols, and Devices / Re: Android Bluetooth joystick on: May 26, 2014, 08:37:42 am
Quote
The swipe-to-close feature is about 40 seconds into video at this site:
http://blog.laptopmag.com/9-awesome-android-ice-cream-sandwich-tips
This method is what was causing problem about no data from Arduino to Android. I wonder if this happens with other users?
I can't replicate the "swipe" problem both on Galaxy Tab3 tablet and Motorola G phone (V4.4.2)
Please let me have a step by step procedure
Pages: 1 2 3 [4] 5 6 ... 26