The RDCM-802 Compass Module is a miniature low-cost orientation-sensing building block suitable for industrial, scientific or hobbyist applications. The module determines the direction in terms of the eight principal compass points, and outputs the result as a 3-bit binary code. The entirely solid-state device contains no moving parts and no coils.
Simple logic circuit to demonstrate the operation.

- compass.gif (11.07 KiB) Viewed 2742 times
| N | NE | E | SE | S | SW | W | NW |
D0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 1 |
D1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 1 |
D2 | 1 | 0 | 0 | 0 | 0 | 1 | 1 | 1 |
Datasheet:
http://www.geosensory.com/pdf/rdcm-802.pdf
Main website:
http://www.geosensory.com/rdcm-802.htm
Good luck!