Forum >Replies by Adam
Replies (4)
  • You Reply: The red one is a bluetooth mate gold.

    The code for the uno is something like:
    [code]


    #include <SoftwareSerial.h> 

    int pin1 = 4;
    int pin2 = 5;
    int pin3 = 6;
    int bluetoothTx = 2;  // TX-O pin of bluetooth mate, Arduino D2
    int bluetoothRx = 3;  // RX-I pin of bluetooth mate, Arduino D3

    int i;
    char command;

    SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

    void setup() {
      for(i=pin1;i<=pin3;i++){
        pinMode(i, OUTPUT);
        digitalWrite(i, LOW);
      }
      Serial.begin(9600);
     
      bluetooth.begin(115200);  // The Bluetooth Mate defaults to 115200bps
      bluetooth.print("$");  // Print three times individually
      bluetooth.print("$");
      bluetooth.print("$");  // Enter command mode
      delay(100);  // Short delay, wait for the Mate to send back CMD
      bluetooth.println("U,9600,N");  // Temporarily Change the baudrate to 9600, no parity
      // 115200 can be too fast at times for NewSoftSerial to relay the data reliably
      bluetooth.begin(9600);  // Start bluetooth serial at 9600*/
     
    }


    void loop()
    {
     

      if(bluetooth.available()){
       
      command = bluetooth.read();

      bluetooth.println(command,DEC);
     
      if(command == '0')
          for(i=pin1;i<=pin3;i++)
              digitalWrite(i, LOW);
      if(command == '1')
            for(i=pin1;i<=pin3;i++)
              digitalWrite(i, HIGH);
      if(command == '2'){
            digitalWrite(pin3, HIGH);
            for(i=pin1;i<=pin2;i++)
              digitalWrite(i, LOW);
      }
      if(command == '3'){
            digitalWrite(pin1, HIGH);
            for(i=pin2;i<=pin3;i++)
              digitalWrite(i, LOW);
      }
      if(command == '4'){
            digitalWrite(pin1, LOW);
            digitalWrite(pin2, HIGH);
            digitalWrite(pin3, LOW);
      }
     
      }
    }

    [/code]

    And the Romeo code is something like:

    [code] int E1 = 5;    //M1 Speed Control
    int E2 = 6;    //M2 Speed Control
    int M1 = 4;    //M1 Direction Control
    int M2 = 7;    //M1 Direction Control

    void stop(void)                    //Stop
    {
      digitalWrite(E1,0);
      digitalWrite(M1,LOW);   
      digitalWrite(E2,0); 
      digitalWrite(M2,LOW);   

    void advance(char a,char b)          //Move forward
    {
      analogWrite (E1,a);      //PWM Speed Control
      digitalWrite(M1,HIGH);   
      analogWrite (E2,b);   
      digitalWrite(M2,HIGH);

    void back_off (char a,char b)          //Move backward
    {
      analogWrite (E1,a);
      digitalWrite(M1,LOW); 
      analogWrite (E2,b);   
      digitalWrite(M2,LOW);
    }
    void turn_L (char a,char b)            //Turn Left
    {
      analogWrite (E1,a);
      digitalWrite(M1,LOW);   
      analogWrite (E2,b);   
      digitalWrite(M2,HIGH);
    }
    void turn_R (char a,char b)            //Turn Right
    {
      analogWrite (E1,a);
      digitalWrite(M1,HIGH);   
      analogWrite (E2,b);   
      digitalWrite(M2,LOW);
    }

    void setup(void)
    {
      int i;
      for(i=4;i<=7;i++)
        pinMode(i, OUTPUT); 
      Serial.begin(9600);      //Set Baud Rate
      Serial.println("Run keyboard control");
      digitalWrite(E1,LOW); 
      digitalWrite(E2,LOW);
      pinMode(2,INPUT);
      pinMode(3,INPUT);
    }

    //String Buttons[17] = {
    //  "J2","J1",NULL,"S2","S1","UP","LEFT","DOWN","RIGHT","1","4","2","3","RZ1","RZ2","LZ1","LZ2"};
    //  // Buttons Nmes

    void loop(void)
    {
      if(Serial.available()){
        //    String n = Buttons();
        char n=Serial.read();
          if(n != -1)
        {
          switch(n)
          {
          case '6'://Move Forward
            advance (255,255);  //move forward in max speed
            break;
          case '8'://Move Backward
            back_off (255,255);  //move back in max speed
            break;
          case '7'://Turn Left
            turn_L (100,100);       
            break;     
          case '9'://Turn Right
            turn_R (100,100);
            break;

          case '1':
            stop();
            break;
          }
        }
        else stop(); 
      }

    }

    [/code]
  • You Reply: Here are the pictures. The breakdown occurred after we put the boards together on top of each other. The lipo was connected to the boards via a breakout cable
    Do you need a more accurate description?
  • You Reply: Using 5x1.5V batteries instead of 5x1.2V worked. Thnak you for the replies.
  • You Reply: To simplify and report on our advances:

    When the board is powered via the battery pack (6V), it restarts every time we try to start the motors with the remote. We found that it works properly only when 1 out of four motors is connected.
    We think that when the usb is connected, it keeps the board powered at a constant +5V and the battery voltage drop does not affect it. (But then again when the board was powered through a 12V power supply, it did not restart, but the motors could not start anyway, which baffles us.)
    So our ideas are to either use a usbcell or buy additional motor drivers so that there is no voltage drop.
    But we also know that there already is a motor driver in the board.

    We have also tried to analyse the schematic and figure out where exactly the vusb and m_vin go. Our conclusion is that we need a power supply that never drops below 5V.

    What do you think?