arduino security

Distance sensor and arduino used to scan room, detect changes, and create ASCII map.

I programmed an Arduino security system to scan the room and detect any changes using a distance sensor mounted to a stepper motor, as part of the university subject Mechatronics 2. An LCD shield was used to interface with the system and switch between calibration mode, security mode, and mapping mode.

Comparison of map generated in mapping mode and polar plot of distance readings.

Mapping mode scanned the room and created an ASCII map of occupied and unoccupied cells. To accomplish this, I created an algorithm that iterated over each cell of the map, and converted the location of the cell to polar coordinates. The angle of the cell was used to find the distance reading taken at the closest angle. The distance of the cell was then compared to the distance sensor reading. If the cell was closer than the sensor reading, it was counted as unoccupied, and if the cell was further away, this meant it was occupied (or behind an object). By generating the map iterating cell by cell, I was able to overcome the memory limitations of the Arduino by printing the map as it was calculated instead of storing the whole map in memory.

Video demonstrating the mapping function and explaining the algorithm behind it.