![Cyber Chasse- SPI Arduino Communication](https://cyberchasse.com/wp-content/uploads/CAP1188-SPI-Arduino-Communication.jpg)
04 Aug CAP1188 SPI Arduino Communication
The CAP1188 offers a large variety of button and proximity functionalities. It’s a turnkey capacitive touch controller, which also encompasses 8 LED drivers. These LED drivers provides full-on / off, dimness controls, variable rate blinking, and breathing. Every LED driver is connected with one of the sensor inputs to actuate when it detects a touch. Besides, each LED driver is individually controlled through a host controller. The low-cost and sturdy touch interfaces works on I2C and SPI protocol. We will be leveraging SPI interfacing in this post.
Key Features
• 8 Capacitive Touch Sensor Inputs
• 8 LED Driver Outputs
• Programmable sensitivity
• Automatic recalibration
• Individual thresholds for each button
• Proximity Detection
• Multiple Button Pattern Detection
• Analog Filtering for System Noise Sources
• Press and Hold feature for Volume-like Applications
• Low Power Operation
Hardware connection:
CAP1188 Arduino
GND GND
5V Vin
MISO 11
MOSI 12
SCK 13
CS 10
RESET 9
IRQ 3
A0 GND
Source code
![CAP1188 SPI](https://cyberchasse.com/wp-content/uploads/2020/08/image-1.png)
![CAP1188 SPI Arduino Communication](https://cyberchasse.com/wp-content/uploads/2020/08/image-2.png)
![Arduino Communication](https://cyberchasse.com/wp-content/uploads/2020/08/image-8.png)
![Arduino Communication](https://cyberchasse.com/wp-content/uploads/2020/08/image-4.png)
Library Downloading:
From the Arduino library manager download the Arduino library.
Open the Arduino library manager.
![Arduino Communication](https://cyberchasse.com/wp-content/uploads/CAP1188-SPI-Arduino-Communication-Library-Downloadin-300x150.jpg)
Search and install the Adafruit CAP1188 library.
![](https://cyberchasse.com/wp-content/uploads/2020/08/image-7.png)
After restarting, load File -> Examples -> Adafruit_CAP1188-> cap1188test sketch
![Arduino Communication](https://cyberchasse.com/wp-content/uploads/CAP1188-SPI-Arduino-Communication-After-restarting-300x150.jpg)
As displayed in the above hardware connection, wire up the connections.
Now upload the sketch, and at 9600 baud, open the serial console. The CAP1188 will be available (good!). You can touch the C1 through C8 pads with your fingers, which will make the sensor go off. Besides, you will see the matching LED lighting up when you touch the pin.
OUTPUT
![Arduino Communication](https://cyberchasse.com/wp-content/uploads/CAP1188-SPI-Arduino-Communication-OUTPUT-300x150.jpg)
![](https://cyberchasse.com/wp-content/uploads/2020/08/image-3.png)
Explanation:
1) Involve all the files similar to adafruit_cap1188.
![CAP1188 SPI Arduino Communication](https://cyberchasse.com/wp-content/uploads/2020/08/image-9.png)
2) Establish all the SPI connections with cap1188. Set all the pins as per the code. Use Reset pin for I2C or SPI. Use CS pin for software or hardware SPI. For SPI communication use MOSI, MISO and CLK pins.
![CAP1188 SPI Arduino Communication](https://cyberchasse.com/wp-content/uploads/2020/08/image-5.png)
3) Start cap1188 SPI function.
![CAP1188 SPI Arduino Communication](https://cyberchasse.com/wp-content/uploads/2020/08/image-6.png)
4) Begin cap1188 sensor with address when you make use of I2C method. Otherwise, use the code given below.
![CAP1188 SPI Arduino Communication](https://cyberchasse.com/wp-content/uploads/2020/08/image-11.png)
5) Turn off multi-touch functionality to allow only one button to be pressed at a time. The function cap.writeRegister has several configurations related to multi touch, led and interrupt.
![CAP1188 SPI Arduino Communication](https://cyberchasse.com/wp-content/uploads/2020/08/image-12.png)
6) Check if a touch is detected in the loop function. Based on the pin, the output will get displayed.
Now, look for interrupt, whenever it detects a touch in the loop due to cap.writeRegister(0x44, 0x41). The routine_Interrupt_CAP1188() interrupt function gets triggered. This increases the value of interrupt, thereby enabling the loop to continue.
If you have any questions related to this topic, do not hesitate to post them on the Comment Box below, and don’t forget to follow us on 👍 Social Networks😉