Enrico Marinoni
/
STM32nucleo-and-SRF04
Understand the way to use HC-SRF04 on STM32 (Nucleo board)
Revision 0:99c5f79155a6, committed 2018-01-02
- Comitter:
- emcu
- Date:
- Tue Jan 02 00:00:18 2018 +0000
- Commit message:
- Understand the way to use HC-SRF04 on STM32 (Nucleo board)
Changed in this revision
diff -r 000000000000 -r 99c5f79155a6 SRF05.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SRF05.lib Tue Jan 02 00:00:18 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/SRF05/#e758665e072c
diff -r 000000000000 -r 99c5f79155a6 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Jan 02 00:00:18 2018 +0000 @@ -0,0 +1,43 @@ + +/* + + By: www.emcu.eu + Date: Jan 2018 + Simple program to read the distance from an SRF04 using the SRF05 library, + the results are send to the PC. + On PC I suggest to use TeraTerm and the configuration is: + 9600 bauds, 8-bit data, no parity + + NOTE: more info are here: http://www.emcu.eu/understand-the-way-to-use-hc-srf04-on-stm32-nucleo-board-and-mbed/ + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + + +#include "mbed.h" +#include "SRF05.h" + +SRF05 srf04_F(PC_7, PB_6); // ECHO (pin.9), TRIG (pin.10) +// SRF05 srf04_D(PA_8, PA_8); // ECHO (pin.7), TRIG (pin.10) + +//------------------------------------ +// Hyperterminal configuration +// 9600 bauds, 8-bit data, no parity +//------------------------------------ +Serial pc(SERIAL_TX, SERIAL_RX); + +int main() +{ +pc.printf("\n\r\n\r By www.emcu.eu \n\r"); + while(1) + { + pc.printf("\n\r\n\r Distance_F = %.1f \n\r", srf04_F.read()); + // pc.printf("\n\r\n\r Distance_F = %.1f - Distance_D = %.1f\n\r", srf04_F.read(), srf04_D.read()); + wait(0.2); + } + } \ No newline at end of file
diff -r 000000000000 -r 99c5f79155a6 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Jan 02 00:00:18 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/7130f322cb7e \ No newline at end of file