The CAP1188 is an 8-channel capacitive touch sensor and is available in a handy breakout board. This module enables I2C communication with the chip to easily get information about which pins are being touched. It's based on Adafruit CAP1188 Arduino libary. Use the CAP1188 (About Modules) module for it.
You can wire this up as follows:
Device Pin | Espruino |
---|---|
1 (GND) | GND |
2 (VIN) | 3.3 |
3 (SDA) | B7 |
4 (SCK) | B6 |
Basic usage:
I2C1.setup({scl:B6,sda:B7});
var cap = require("CAP1188").connect(I2C1);
cap.readTouches();
// Returns an array of 8 items for pins C1 - C8
// true indicates a touch, false is no touch
Optionally, you can connect the reset pin on the board (marked RST), to a pin on the Espruino. Call the reset()
method to reinitialize the sensor. An optional callback can be supplied that's called when the board has been reset.
var cap = require("CAP1188").connect(I2C1, { resetPin: B15 });
cap.reset(function () {
// the board has been reset
});
This page is auto-generated from GitHub. If you see any mistakes or have suggestions, please let us know.