Filled under: Electronics, Projects

Date posted: November 4, 2013

Fall 2013 my engineering professor asked me to create a lab for her MATLAB class and I gladly took on the challenge. Having been an engineering student for almost two years and interacting with dozens of other engineering students, I noticed many students have difficulty relating abstract material, especially programming, to the real world. I wanted the MATLAB lab to interact with the world world in some way making a connection between the tangible and the abstract.

My first thought was making a sonar sensor and placing it in front of several objects so students will have to construct a graphic map of the environment using data imported into MATLAB. I took this idea a step farther and wondered if the sonar could be mounted on wheels and the students would have to create code to control the robot to navigate those obstacles, like a rat in a maze. Then I realized that idea was going outside the specialty of MATLAB, matrix manipulation . I needed a new idea.

After an hour of contemplation,  thoughts coalesced in one idea: an encrypted data source students will have to collect, parse, decrypt, and feedback into the system for a desired, real world result. A puzzle box was created.


The Black Box has a circular locked door that will only open when the correct passcode is flashed into the light sensor. The encrypted passcode is collected by placing the Sensor Box’s light sensor over the Black Box’s flashing LED which then may be decrypted in MATLAB using a specific procedure outlined in the lab write up. The Sensor Box contains a LED that is controlled in MATLAB and may be placed over the Black Box’s light sensor to open the Black Box with the correct passcode. The Sensor Box connects to MATLAB via the USB emulating a serial connection.

The lab procedure sheet is as follows, or download it:

black_box_matlab_lab-page-002black_box_matlab_lab-page-003 black_box_matlab_lab-page-004black_box_matlab_lab-page-005black_box_matlab_lab-page-006black_box_matlab_lab-page-007

The solution code is as follows:



The Black Box has two servos, one for the door and one as a lock so the door can not be manually opened.


The system is powered by an Arduino Nano.