Collision Avoidance Detecting Object

Hi guys,

Does anyone know the code for flashing an LED when the quadcopter is less than 30 cm away from the target? I am using two sensor and this means I have 2 LED, one for sensing target from the left and one for sensing target from the right. Between I am using timer 3 for arduino micro.

if (distance < 30) {
   flashLED();
}

Somehow I think you were expecting a more useful answer. But the problem is that you have not provided the necessary information.

Where are the sensors - are they on the 'copter or on the ground?
Where will the LED be?
What sort of sensors?
Can the sensors report distance ?

and I am sure there are many other relevant questions

…R

Im using the MB1010 LV-MaxSonar-EZ1 and the sensor is at the side of the cop.

The LED will be on top of the cop together with the Arduino Micro.

Yes the sensors can report distance.

Are you planning to have a Micro to read the sonar data and flash the LED quite independently of the “computer” that controls the 'copter. That would be much easier than tinkering with the control software. Plus you can develop all the code on your desk and add it to the 'copter when it works.

I suspect there is example code for that sonar device but I can’t be sure as you did not post a link to its datasheet.

If it was my project I would have code in loop() something like this

void loop() {
   readSonar();
   if (distance < 30) {
       flashLED();
   }
}

There is code for flashing LEDs in Several Things at a Time

…R