Chapter 15 Built-In Sensors
The CPX has numerous built-in sensors. These include a light sensor, an IR sensor, an accelerometer, a microphone, a speaker, some neopixels, a temperature sensor and 8 analog inputs with ADCs and even I2C (pronounced I squared C - itβs a kind of serial communication) that you can use to easily hook up more sensors to it. Weβre not going to utilize all of these sensors since that would be a rather large project. Instead weβre going to learn how to use the temperature, light and sound sensors as well as the accelerometer. For each of these examples there is a relatively easy way to access the sensors using a built-in module called adafruit_circuitplayground.express if you are using the CPX. If you are using the CPB you need to type adafruit_circuitplayground.bluefruit. Itβs a very nice module because it imports everything on the board. Section SectionΒ 7.2 goes over the steps required to install different modules on the CPX/CPB. The problem is you can run into module conflicts. This happens when two different modules try to access the same pins on the CP. Sometimes if you import adafruit_circuitplayground you wonβt be able to import some other modules. Note you might need to add the adafruit_circuitplayground library to your lib/ folder on your CIRCUITPY drive. Due to this module conflict issue, there are some low level control commands you can use to access each of the sensors on board. Weβre obviously going to learn the low level control method first and then Iβll show you how to access the sensors using the adafruit_circuitplayground module. If you get a currently in use error it means you have a module conflict. Hence why Iβm showing you the low level control method.
