Ultrasonic range sensor with quadrino nano

Hi,
I got quadrino nano flight controller. I have not worked with flight controllers before. Though I know arduino.
I am trying to connect ultrasonic range sensor with quadrino nano. I connected the sensor wiith serial3 pins of quadrino.
How do I call serial3 TX and RX pins in arduino code?
Thanks,
Abhishek

Hi Abhishek,

You might have to test the port if it’s the right one. (which number 1 / 2 / 3)
In your code just follow the Arduino examples for serials.

SerialX.begin(9600);

Where X is the serial number

Hi,
Thanks for the reply.

I guess I have a more basic question.
How to connect ultrasonic range sensor with quadrino nano and blink an LED based on obstacle proximity?

This is how I connect the sensor with quadrino nano, and the arduino code is the following:

const int TrigPin = 0;
const int EchoPin = 1;

float cm;
void setup()
{
Serial.begin(9600);
pinMode(TrigPin, OUTPUT);
pinMode(EchoPin, INPUT);
pinMode(LED_BUILTIN, OUTPUT);
}
void loop()
{
digitalWrite(TrigPin, LOW);
delayMicroseconds(2);
digitalWrite(TrigPin, HIGH);
delayMicroseconds(10);
digitalWrite(TrigPin, LOW);
cm = pulseIn(EchoPin, HIGH) / 58.0; //The echo time is converted into cm
cm = (int(cm * 100.0)) / 100.0; //Keep two decimal places
/cm = random(0, 50);/
Serial.print(“Distance\t=\t”);
Serial.print(cm);
Serial.print(“cm”);
if (cm < 10) {digitalWrite(LED_BUILTIN, HIGH);}
else {digitalWrite(LED_BUILTIN, LOW);}
Serial.println();
delay(100);
}

Output on the serial monitor is “Distance = 0.00 cm”.

This is first time I am working with flight controller. Could you suggest where to start?
I see a lot of files here:
http://www.lynxmotion.com/s-4-electronics-guides.aspx

Any recommendation where to start.

Thanks a lot for your time and help.
Verma

I’ve tested a config here:

1 - Connect your sensor in Serial3 with the connector colors as mine
2 - Load the library attached (adding library)
3 - Open the “HC_SR4_Quadrino” example and load it
4 - Serial monitor should send you the distance

Note: This is not a Serial communication sensor, but you can use the pins as digitals and it work.

Ultrasonic.zip (2.2 KB)

Hi,

Thank you. I really appreciate the help :slight_smile:
I will try the steps you told.
I am starting a UAV lab from scratch and quadrino nano seems a good platform to use.

Thanks,
Abhishek