Accessing the compass programmatically
In order to access the compass capability, you'll need to enable the I2C library on Raspberry. If you used the IR sensor and ADC additional hardware in Chapter 4, Avoiding Obstacles Using Sensors, you will have already done this. If not, follow these instructions to enable the I2C interface:
- Run
raspi-config
. Select the Configure advanced settings, as shown in the following screenshot:From the next selection page, select the Enable/disable automatic loading of the I2C interface, as shown in the following screenshot:
Then select yes, as shown in the following screenshot:
You'll also want to edit the file
/etc/modules ...
Get Raspberry Pi: Amazing Projects from Scratch now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.