top of page

Arduino Sonar

Recently I've found out that Mathworks provides code generator for Arduino - Arduino Support from Simulink. So, I've decided to try how it works in practice.

 

My first idea was to create sonar. I used Arduino Mega, Adafruit Motor Shield, cheap DC Motor and HC-SR04 ultrasonic sensor. Program was created in Matlab Simulink. I used 2 libraries: AFMotor - to control DC Motor, NewPing - to decode data received from sensor. 

There was only one problem - how to use functions and classes from standard Arduino libraries in Simulink? I googled very intersting website: www.minseg.com and find out how to build S-Functions that "wrap" functions from Arduino libraries. 

 

When I managed to solve the problems with Simulink I put togehter the hardware and start testing my Arduino Sonar. I presented the final effect in short movie on my youtube channel:

Additional documentation you find here:

 

Source with documentation you will find here:

I also prepared manual how to integrate Arduino libraries with Matlab Simulink:

Text transcript of this movie you can download from this site:

 

Source with full documentation you will find here:

 

 

bottom of page