I integrated it in my MW 2.3 Gui version and connected to MultiWii Pro FC, yesss its work.
I copy code from this topic, but i edit main function.
Sensors.cpp
look for this lineCode: Select all
// ************************************************************************************************************
// I2C Sonar SRF08
// ************************************************************************************************************
// first contribution from guru_florida (02-25-2012)
//
#if defined(SRF02) || defined(SRF08) || defined(SRF10) || defined(SRC235)
.
.
.
.
.
#else
void Sonar_init() {}
void Sonar_update() {}
#endif
and in theCode: Select all
#else
inline void Sonar_init() {}
void Sonar_update() {}
#endif
change the two line inside the #else and #endif to thisCode: Select all
#if defined(SONAR_GENERIC_ECHOPULSE)
// ************************************************************************************************************
// Generic Sonar Support
// ************************************************************************************************************
void Sonar_init()
{
pinMode(SONAR_GENERIC_TRIGGER_PIN, OUTPUT);
pinMode (SONAR_GENERIC_ECHO_PIN, INPUT);
}
void Sonar_update()
{
long temp;
digitalWrite(SONAR_GENERIC_TRIGGER_PIN, LOW);
delayMicroseconds(2);
digitalWrite(SONAR_GENERIC_TRIGGER_PIN, HIGH);
delayMicroseconds(5);
digitalWrite(SONAR_GENERIC_TRIGGER_PIN, LOW);
temp = pulseIn(SONAR_GENERIC_ECHO_PIN, HIGH) / SONAR_GENERIC_SCALE;
sonarAlt = (temp >= 0 && temp <= SONAR_GENERIC_MAX_RANGE) ? temp : 0;
}
#else
inline void Sonar_init() {}
void Sonar_update() {}
#endif
Yes, in Sensors.cpp its main metod.
And it work.
MultiWii Pro FC + HC-SR04
https://dl-web.dropbox.com/get/sonar/20150425_235502.jpg?_subject_uid=67557891&w=AABwwmhRSyyET_KurrNsJEFaVPs9lLX6pl2wshthqvjIhA
https://dl-web.dropbox.com/get/sonar/20150425_235356.jpg?_subject_uid=67557891&w=AADsv4IpKITB2Bo2xOt6at1Osqc-cnx2fEAp5cFtq5Wk0g
https://dl-web.dropbox.com/get/sonar/20150425_235429.jpg?_subject_uid=67557891&w=AAAtSuTfsX7uPdx7PEp2c_I5oWgIcVN0AcubWsNCYyIy2g
P.S. sorry for my english