How to integrate RoboRemo in my code?

View previous topic View next topic Go down

How to integrate RoboRemo in my code?

Post by cuchara on Tue Jun 28, 2016 8:44 pm

How to integrate RoboRemo in my code?

HI
Sorry I does not know much about programming but I can modify some simple codes
I would like to know that part of code and libraries I need to add to my arduino to communicate with my phone

this is my code I use five buttons and 1 potentiometer


Code:

  #include<Wire.h>
  #include<LiquidCrystal_I2C.h>
 
  #include <Servo.h>
  
  
  #define bmod      5
  
  #define bm0         6
  #define bm1        7
  #define bm2        8
  
 
  #define bmenos    11
  #define bmas      12
  
  #define potpin    A0
  #define servopin  9
  

 LiquidCrystal_I2C lcd(0x27,16,2);
  
  int     pot = 0;
  int lastpot = 0;   
  int  servoValue;
  Servo   myservo;
  int   modo = -1;
  int   mem0 = -1;
  int   mem1 = -1;
  int   mem2 = -1;
  int retardo = 1;                        // two memories to hold servo positions
  int    blik = 0;                        // del is the param to manage the delay (1/speed) of the servo.
 /////////////////////////////////////////////////////////////////////////////////////////                                            
 void setup()
 {
  lcd.init();
  lcd.backlight();
  
  lcd.begin(16, 2);
    
  Serial.begin(9600);
  Serial.println("Start ..");

  pinMode(bmod, INPUT);
  pinMode(bm0, INPUT);  
  pinMode(bm1, INPUT);
  pinMode(bm2, INPUT);
  
  pinMode(bmas, INPUT);
  pinMode(bmenos, INPUT);

  
  digitalWrite(bmod, HIGH);
  digitalWrite(bm0, HIGH);  
  digitalWrite(bm1, HIGH);                // internal pullup
  digitalWrite(bm2, HIGH);
  
  // internal pullup
  digitalWrite(bmas, HIGH);               // internal pullup
  digitalWrite(bmenos, HIGH);             // internal pullup

  myservo.attach(9);
  servoValue = 0;
  myservo.write(servoValue);                     // set servo to mid-point
 
    
  }
////////////////////////////////////////////////////////////////////////////////////////
  void loop()
  {
    {
    lcd.setCursor(10,1);lcd.print("B1");
    lcd.setCursor(7,1);lcd.print("B2");
    lcd.setCursor(13,1);lcd.print("B0");
    
    lcd.setCursor(3,0);lcd.print(pot);
    lcd.setCursor(0,0);lcd.print(retardo);
    
    lcd.setCursor(10,0);lcd.print(mem1);
    lcd.setCursor(7,0);lcd.print(mem2);
    lcd.setCursor(13,0);lcd.print(mem0);
    
    lcd.setCursor(3,1);lcd.print("Pot");
    lcd.setCursor(0,1);lcd.print("Sp");}
  
                                                                          // READ POT
  pot = analogRead(potpin);                                                    // 0..1023
  if (abs(lastpot -pot) < 3) pot = lastpot;
  else lastpot = pot;
  servoValue = map(pot,0,1023,0,180);
                                                                              // servoValue = pot; //4;

                                                                              // CHECK BUTTONS PRESSED
                                                                             // position buttons
  if (digitalRead(bm0) == LOW)                                                // pressed
     { if (mem0 == -1)                                                    // not pressed before
     {mem0 = servoValue;}                                                 // remember current value
   else {servoValue = mem0;}}                                                 // set remembered value
    
  if (digitalRead(bm1) == LOW)                                                // pressed
   {if (mem1 == -1)                                                            // not pressed before
     {mem1 = servoValue;}                                                 // remember current value
    else
     {servoValue = mem1;}}                                                 // set remembered value
      
  if (digitalRead(bm2) == LOW)  
   {if (mem2 == -1)
    {mem2 = servoValue;}
    else
    {servoValue = mem2;}}
    
                                                                              // speed buttons
  if (digitalRead(bmas) == LOW)
       retardo = max(retardo-=1, 0);
  if (digitalRead(bmenos) == LOW)
        retardo = min(retardo+=1, 99);                                         // value can be tweaked
    Serial.println(retardo);

  Serial.print("SERVO: ");
  Serial.println(servoValue);
  Serial.print(" speed: ");
  Serial.println(retardo);
                                                                                // speed button
  int start = myservo.read();                                                 // get current position;
  int stop = servoValue;                                                      // new position
  if (start != stop)
  {
    int step = (stop - start)>0?1:-1;
    for (int i=start; i!=stop; i+= step)
    {
      myservo.write(i);
      delay(retardo);
     }
   }    
 }



thanks for your time

cuchara

Posts : 4
Join date : 2016-06-28

View user profile

Back to top Go down

Re: How to integrate RoboRemo in my code?

Post by Admin on Wed Jul 13, 2016 7:30 am

Hi,
First sorry for replying so late,
Unfortunatelly I don't have too much time because I have to work on other projects too.

Here are some ideas for your code:

- change
Serial.println("Start ..");
to
Serial.println("dbg Start ..");

then in RoboRemo add a text log and set id to "dbg" (without "") so it will log all the strings that you are sending

- for these:
Serial.print("SERVO: ");
Serial.println(servoValue);
Serial.print(" speed: ");
Serial.println(retardo);

add in RbooRemo 2 level indicators and set the ids to "SERVO:" and " speed:"

Admin
Admin

Posts : 111
Join date : 2016-03-08

View user profile http://roboremo.makeforum.net

Back to top Go down

Re: How to integrate RoboRemo in my code?

Post by cuchara on Thu Jul 14, 2016 12:30 am

Thank you very very much..... I'll try what you tell me

But this part is not very clear to me

then in RoboRemo add a text log and set id to "dbg"

where I put that?

I'm making a video
I will send many people to download your app
Thanks

cuchara

Posts : 4
Join date : 2016-06-28

View user profile

Back to top Go down

Re: How to integrate RoboRemo in my code?

Post by Admin on Thu Jul 14, 2016 8:51 am

I mean you open RoboRemo, press menu -> edit ui, then click on blank space and add a text log, then click on it and select "set id" and enter "dbg" (without "" ), then press menu -> don't edit ui, then connect to the Arduino (you can connect the Arduino directly to the USB of the phone if your phone supports USB OTG and API), or use a Bluetooth module like HC-05.
Then, when you send something from Arduino using Serial.println("dbg sometext"), "sometext" will appear in the text log.
I use the "dbg" for debug, but you can change it to whatever you want, just make sure it is the same in both RoboRemo text log and Arduino Serial.println.

Admin
Admin

Posts : 111
Join date : 2016-03-08

View user profile http://roboremo.makeforum.net

Back to top Go down

Re: How to integrate RoboRemo in my code?

Post by cuchara on Thu Jul 14, 2016 6:20 pm

Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Thank Very Happy Very Happy Very Happy Very Happy Very Happy

cuchara

Posts : 4
Join date : 2016-06-28

View user profile

Back to top Go down

Re: How to integrate RoboRemo in my code?

Post by cuchara on Sun Jul 24, 2016 7:23 pm

Hello again  Smile

With what you tell me to change I can only see what the LCD shows..
but I would like to control the arduino with each of the buttons etc..  pale  

  #define bm0         6
 #define bm1        7
 #define bm2        8
 #define bmenos    11
 #define bmas      12
 #define potpin    A0
 #define servopin  9

To modify the app I have no problem is very simple.... but to change the cod I do not understand  what  I have to do Crying or Very sad Crying or Very sad Crying or Very sad

Can you explain me please or show a good example that goes with my cod??

THANKS

cuchara

Posts : 4
Join date : 2016-06-28

View user profile

Back to top Go down

Re: How to integrate RoboRemo in my code?

Post by grb352 on Mon Jul 25, 2016 12:08 am

lots of examples here:
http://www.roboremo.com/projects.html

you will need to learn to modify them for your use.

grb352

Posts : 11
Join date : 2016-05-22

View user profile

Back to top Go down

Re: How to integrate RoboRemo in my code?

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum