View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Autonomous 4-Wheel Robot Light Tracker - Arduino Mega 2560

Be the first to rate this file! 15 Downloads (last 30 days) File Size: 413 KB File ID: #36938 Version:

Autonomous 4-Wheel Robot Light Tracker - Arduino Mega 2560


Dan Lluch (view profile)


04 Jun 2012 (Updated )

Simulate and deploy a Run on Target Hardware Arduino algorithm that tracks light and detects bumps.

| Watch this File

File Information

A sample model that implements light following and bump detection algorithms on a 4-wheel autonomous vehicle with an Arduino Mega 2560 onboard. The light following algorithm is based on two light sensors mounted in the front of the vehicle that when a difference is sensed, the vehicle turns towards the brighter side. Also implemented is that the vehicle drives faster when the light is dim (proxy for ‘far’), and slower when it is bright (proxy for ‘close’). Bump logic is done with left/right bump sensors, and the vehicle backs up and then turns away from the object it struck.
The model is created in a way to allow for simulation and code generation. Numerous test scenerios are implemented with a Signal Builder block to test aspects of algorithms prior to trying on the final platform.
External mode can be toggled to allow for monitoring of signals and tuning of parameters, and the model currently implements the back_time parameter as tunable when an object is struck.
The ZIP file includes the listing of hardware used, wiring schematics. It is encouraged to continue to expand on more complicated and robust algorithms, new sensors/actuators, etc.

For more information, please refer to:
- Simulink Targets:
- Arduino Support from Simulink:
- Support Package for Arduino Mega:

Facecast was on June 7, recorded video can be located here - (Arduino Support from Simulink video)


Simulink Support Package For Arduino Uno Hardware (R2012a), Simulink Support Package For Arduino Uno And Mega 2560 Hardware (R2012b), and Simulink Support Package For Arduino Hardware inspired this file.

Required Products Simulink
MATLAB release MATLAB 7.14 (R2012a)
Other requirements Have installed the Support Package for Arduino Mega 2560 - run targetinstaller at the command prompt
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
28 May 2013 Dan Lluch

Dan Lluch (view profile)

@ IceCube - yes this is possible. I think the first step would be to offset sensors vertically, such that you can sense brightness differences in that axis as well. you can then move to design a controller that takes this information appropriately and generates commands (and adjust the plant itself to be able to actuate something in that axis as appropriate). I will leave the community to continue to explore this. Maybe consider posting to MATLAB Answers to see if a group would like to explore this topic further?

Comment only
22 May 2013 IceCube

This is one axis tracker, can you make a two axis tracker with closed-loop controller?

Comment only
04 Jun 2012 1.1

update ZIP file

04 Jun 2012 1.2

- updated picture for file view of model, and included Simulink Web View files

08 Jun 2012 1.3

 added link to recorded facecast in description

06 Sep 2013 1.6

adding Support Packages for Arduino as acknowledgements on this entry.

01 Sep 2016

Updated license

Contact us