Do you think i can use a breadboard to split the signal wire of the servos in 2 ? ( one will go on the receiver and one on a arduino pin )
And i define the arduino pin as output so the signal is not interfered ?
Thank you
Pierre
Do you think i can use a breadboard to split the signal wire of the servos in 2 ? ( one will go on the receiver and one on a arduino pin )
And i define the arduino pin as output so the signal is not interfered ?
Thank you
Pierre
Do you think i can use a breadboard to split the signal wire of the servos in 2 ? ( one will go on the receiver and one on a arduino pin )
I am not sure that you have completely grasped what is being proposed
The signal wire from the receiver goes to an Arduino input pin
The signal wire to the servo goes to a different Arduino output pin
During normal operation the Arduino passes the signal from the input pin through to the output pin and hence to the servo. If an obstacle is detected then the Arduino ignores the input and outputs a different signal to the output pin
Hi Pierre,
Here's an image of my set up.
The servos are being powered from the Lipo battery via the ESC's +5V BEC (Battery Elimination Circruit).
The Arduino is being powered (in this instance) from the Arduino's USB port. Although on-board an aircraft, it would be powered from a separate (Arduino or externally regulated) supply, usually going back to the same battery. The receiver is being powered from the Arduino's 5V regulated supply.
The only connection between the two systems is the Arduino's servo control signals (2 yellow wires) and the Arduino's ground (single black wire) back to the common point on the breadboard. The receiver input signals are the white wires.


thx for the picture .But do you have the code so that the servos are linked to the receiver (because there is a Elevon mode in my rc controller that can control the servo specificaly for a plane or wing model) and control the servo directly from the Arduino( So if the sonarsensors detects a obstacle the arduino tells the servos to move ).
This is the code that i made in advance. Can you please tell me how can i modify it if i follow your setup ?(or what you recommend). Thank's a lot
#include<Servo.h>
Servo myservo1;
Servo myservo2;
#define servoPin 2
#define servoPin 3
#define trigD1 9
#define echoD1 8
#define trigD2 7
#define echoD2 6
#define trigD3 5
#define echoD3 4
long duration , distance ,distance1, distance2, distance3, difference, absDiff;
int angle = 0;
void setup(){
pinMode(trigD1, OUTPUT);
pinMode(echoD1, INPUT);
pinMode(trigD2, OUTPUT);
pinMode(echoD2, INPUT);
pinMode(trigD3, OUTPUT);
pinMode(echoD3, INPUT);
myservo1.attach(servoPin);
myservo2.attach(servoPin);
Serial.begin(9600);
}
void loop() {
SonarSensor(trigD1, echoD1);
distance1 = distance;
SonarSensor(trigD2, echoD2);
distance2 = distance;
SonarSensor(trigD3, echoD3);
distance3 = distance;
myservo1.write(90);
myservo2.write(90);
difference = (distance1-distance2);
absDiff = abs(difference);
if (distance1 <= 350 && distance1 !=0 && distance2 <= 350 && distance2 !=0 && distance3 <= 350 && distance3 !=0){
myservo1.write(65);
myservo2.write(65);
if (distance1 >=500 && distance2 >= 500 && distance3 >=500){
myservo1.write(90);
myservo2.write(90);
}
}
if (distance2 <= 350 && distance2 !=0 && distance1 <= 350 && distance1 !=0){
myservo1.write(115);
myservo2.write(65);
if (distance1 >=500 && distance2 >= 500 && distance3 >=500){
myservo1.write(90);
myservo2.write(90);
}
}
if(distance3 <= 350 && distance3 != 0 && distance1 <=350 && distance1){
myservo1.write(65);
myservo2.write(115);
if (distance1 >=500 && distance2 >= 500 && distance3 >=500){
myservo1.write(90);
myservo2.write(90);
}
}
}
void SonarSensor(int trigPin,int echoPin)
{
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
}
@jtrox04
Please follow the advice on posting a programming question given in Read this before posting a programming question
In particular note the advice to Auto format code in the IDE and to use code tags when posting code here
Hi Pierre,
But do you have the code so that the servos are linked to the receiver (because there is a Elevon mode in my rc controller that can control the servo specificaly for a plane or wing model) and control the servo directly from the Arduino( So if the sonarsensors detects a obstacle the arduino tells the servos to move ).
A basic implementation of elevon servo mixing is as follows:
void loop()
{
noInterrupts(); // Copy the callback function pulse widths values
pulsewidth.airelon = isrPulsewidth.airelon;
pulsewidth.elevator = isrPulsewidth.elevator;
interrupts();
int elevator = pulsewidth.elevator - 1500; // Subtract servo centre point
int elevonA = pulsewidth.airelon + elevator; // Mix the servo (elevon) outputs
int elevonB = pulsewidth.airelon - elevator;
elevonA = constrain(elevonA, 1000, 2000); // Ensure that the output is within bounds
elevonB = constrain(elevonB, 1000, 2000);
OCR1A = elevonA; // Load timer1 with the pulse widths
OCR1B = elevonB;
}
I suggest you install the digistumparduino libraries. Within that set of libraries there is a DigisparkSoftRcPulseIn function that reads a servo signal from your receiver ( or from a servo tester) and a function DigisparkSoftRcPulsOut that will create a servo signal to any RC servo. The library comes with examples that you should look at first. Good luck.
I have used this library to make a flight stabilization for my combat wing combined with a gyro sensor. I doubt if the ultrasonic sensor has enough range to avoid hitting something, unless you fly very slow (e.g. F3P indoor flying). maybe first connect it to your combat wing and turn on a led if it sees something, so you can check if your sensor concept works in flight.
Ultrasonic sensors have 4 m range so i think it's enough. If not do you have a suggestion for another type of sensors ?
thank you
Pierre
I assume ultrasonic gets 4 meter if it is a quiet environment with a wall to reflect sound pulses? Maybe I am too pessimistic and i should connect one in my own combat wing and send it's values by telemetry.
I have been experimenting with a HB100 microwave motion sensor, to have ground proximity avoidance on my elevator but my first built pre-amplifier was too noisy to give me a useable signal. Need to build a better one.
I fear i will end up with some more expensive lidar sensors
I think you'r totally right buddy .I found on aliexpress a 20 $ lidar sensor named benewake tf luna with 8m of range i have to buy 3 it will be expensive af. But do you think it's better to buy the 44 $ one with 12 m of range ?
Pierre
I can't tell. have not used either of them. I would buy one of the $20 Lidar sensors first test if that works for you. Smallest financial risk if it fails, and who knows it may become handy for something else later.
Cordialement, Hans
Thank you for your fast respond i will follow your recomendation and learn how to use them on arduino.
Again thx
Pierre
Hi I am building a obstacle avoiding fixed wing but for that i have to use a flight controller and a arduino . So i have to connect 2 servos to the arduino(so when the sensors detects something it can execute the code to make the servos move and like so avoid the obstacle) And at the same time i have to connect these 2 servos to the flight controller so it can stabilize the aircraft and i can controlle it from a transmitter(and of course to execute return to home and all these cool stuff).
So i had i idea . If i conect the signal wire to a breadboard (one wire will go to the flight controller and the other to the arduino) will it work ?
thank you .
Pierre
Two topics merged so that today's post can be seen in context