Help With Code for PS3 Bluetooth Robot Control


hi guys i'm relatively new arduino , new form! can offer me appreciated!

so i'm making bluetooth controlled robot sainsmart motor bridge, usb 2.0 host, bluetooth dongle, ps3 controller, , etc. think general idea. anyways got circuitry , stuff , running i'm having trouble code. i've been teaching myself code i'm not best haha.

anyway here problem: i'm trying thing working on simple test run 1 motor when press x button on ps3 controller. got working doesn't stop when let go -_-

any ideas what's wrong?

here code:

#include <ps3bt.h>
#include <usbhub.h>
// satisfy ide, needs see include statment in ino.
#ifdef dobogusinclude
#include <spi4teensy3.h>
#endif

usb usb;
//usbhub hub1(&usb); // dongles have hub inside

btd btd(&usb); // have create bluetooth dongle instance so
/* can create instance of class in 2 ways */
ps3bt ps3(&btd); // create instance
//ps3bt ps3(&btd, 0x00, 0x15, 0x83, 0x3d, 0x0a, 0x57); // store bluetooth address - can obtained dongle when running sketch

boolean printtemperature;
boolean printangle;

//variables
  int enablea = 3;
  int enableb = 6;
  int in1 = 1;
  int in2 = 2;
  int in3 = 4;
  int in4 = 5;
 

void setup(){
   serial.begin(115200);
  while (!serial); // wait serial port connect - used on leonardo, teensy , other boards built-in usb cdc serial connection
  if (usb.init() == -1) {
    serial.print(f("\r\nosc did not start"));
    while (1); //halt
  }
  serial.print(f("\r\nps3 bluetooth library started"));
  pinmode(enablea, output);
  pinmode(enableb, output);
  pinmode(in1, output);
  pinmode(in2, output);
  pinmode(in3, output);
  pinmode(in4, output);
}

void loop(){
  usb.task();
 
    if (ps3.ps3connected || ps3.ps3navigationconnected) {
      if(ps3.getbuttonclick(cross) == high){
      delay(10);
      analogwrite(enablea, 255);
      digitalwrite(in1, high);
      digitalwrite(in2, low);
   }
    if (ps3.getbuttonclick(ps)) {
      serial.print(f("\r\nps"));
      ps3.disconnect();
    }
}
}


thanks in advance!

quote
i got working doesn't stop when let go -_-

code: [select]
      if(ps3.getbuttonclick(cross) == high){
      delay(10);
      analogwrite(enablea, 255);
      digitalwrite(in1, high);
      digitalwrite(in2, low);

if switch pressed, start motor. if isn't, nothing. well, no wonder motor never stops.


Arduino Forum > Topics > Robotics (Moderator: fabioc84) > Help With Code for PS3 Bluetooth Robot Control


arduino

Comments

Popular posts from this blog

opencv3, tbb and rasp pi 2 - Raspberry Pi Forums

small ethernet problem - Raspberry Pi Forums

Multithumb configuration params not working? - Joomla! Forum - community, help and support