Problems sending data with two eb301 bluetooth modules and two arduinos

the serial monitor is connected to the tx code. im using one of my homemade arduinos for the rx side so i can't hook it to the serial monitor, that i know how anyway lol

jeremybgilbert:
the serial monitor is connected to the tx code. im using one of my homemade arduinos for the rx side so i can’t hook it to the serial monitor, that i know how anyway lol

Too bad, it would make it easier if you were hooked up to the rx side, but doesn’t matter.

If that test loop() function for the receive sketch moves the servos through the expected range, it means the problem is with the reception of values, rather than controlling the servos. If it moves the servos, but through a limited range, then the inverse mapping will have to be fixed. If it doesn’t move them at all, then it doesn’t matter what the transmit side is doing… nothing is going to happen in any case until the basic servo control gets fixed.

that test loop code did nothing for it :/ but the servos arent bad.

jeremybgilbert: that test loop code did nothing for it :/ but the servos arent bad.

They may be OK, but the software isn't. The best hardware will do nothing until the software is correct.

Have you an example sketch using the "SoftwareServo" lib that moves the servos at all? Perhaps there is an initialisation step you need to include. (Sorry, I'm not familiar with the "SoftwareServo" lib.)

Post that and I'll see if I can spot something that might need to be included in your receive sketch.

i took that from the example code from the arduino lib that came with the downloaded software. so honestly im not even sure if it needs the softwareservo.lib

jeremybgilbert:
i took that from the example code from the arduino lib that came with the downloaded software. so honestly im not even sure if it needs the softwareservo.lib

You’ll certainly need a servo lib of some description to interface your servos to the Arduinos. You didn’t get any of the test/example sketches working with your servos before you started your own sketches? Thats’ usually the way to get started, so you know the hardware set-up is compatible with the software assumptions.

this one worked but it’s using one arduino with the servos and joystick attached

#include <Servo.h> 
Servo myservo1;
Servo myservo2;

int potpin1 = 0;  //analog input pin A0
int potpin2 = 1;

int newval1, oldval1;
int newval2, oldval2;

void setup() 
{
  Serial.begin(9600);  
  myservo1.attach(2);  
  myservo2.attach(3);
  Serial.println("testing dual pot servo");  
}

void loop() 
{ 
  newval1 = analogRead(potpin1);           
  newval1 = map(newval1, 0, 1023, 0, 179); 
  if (newval1 < (oldval1-2) || newval1 > (oldval1+2)){  
    myservo1.write(newval1);
    Serial.print("1- ");
    Serial.println(newval1);
    oldval1=newval1;
  }

  newval2 = analogRead(potpin2);
  newval2 = map(newval2, 0, 1023, 0, 179);
  if (newval2 < (oldval2-2) || newval2 > (oldval2+2)){  
    myservo2.write(newval2);
    Serial.print("2- ");    
    Serial.println(newval2);
    oldval2=newval2;
  }
  delay(50);
}

jeremybgilbert:
this one worked but it’s using one arduino with the servos and joystick attached

#include <Servo.h>

Well, the first thing that jumps out at me is you are USING A DIFFERENT LIBRARY!

Trying including

#include <Servo.h>

in your receive sketch rather than

#include <SoftwareServo.h>

Try the test sketch again, this time with with correct library included, and see if things move this time.

Edit: Just out of interest, where did the #include <SoftwareServo.h> come from?

yes, i tried using that library first but it never worked so i replaced it with the softwareservo i cannot remember where i saw the softwareservo at. some sample code online ive tried both of them with the receiver code but neither works

jeremybgilbert: yes, i tried using that library first but it never worked so i replaced it with the softwareservo

You mean it didn't work with the original tx/rx sketches you wrote? Well, that's not surprising, given the problems that have been identified with it earlier. Let's get the servos working with the test sketch, then we'll get the proper version going.

Edit: BTW, the test sketch will take about 90 seconds to move the servos through their entire range. Deliberately slow, I wasn't sure what you are connected up to and I didn't want to potentially break or stress anything.

right now the servos arent attached. they will be a pan/tilt when the codes are working lol

jeremybgilbert: right now the servos arent attached. they will be a pan/tilt when the codes are working lol

But they are connected to the Arduino, so you can see them move (if they are going to move)?

yes thats correct

jeremybgilbert: yes thats correct

Good, I thought as much. Just making sure we're on the same page!

If you can get the servos to move properly with the test sketch, I think we'd be fairly close to getting it working.