Skip to content

Commit 746164b

Browse files
working, added readme
1 parent f3ddff0 commit 746164b

File tree

6 files changed

+611
-0
lines changed

6 files changed

+611
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Render Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- ".github/workflows/render-documentation.ya?ml"
9+
- "examples/**"
10+
- "src/**"
11+
pull_request:
12+
branches:
13+
- main
14+
paths:
15+
- ".github/workflows/render-documentation.ya?ml"
16+
- "examples/**"
17+
- "src/**"
18+
workflow_dispatch:
19+
20+
jobs:
21+
render-docs:
22+
permissions:
23+
contents: write
24+
uses: arduino/render-docs-github-action/.github/workflows/render-docs.yml@deps-install-fix
25+
with:
26+
source-path: './src'
27+
target-path: './docs/api.md'
28+
fail-on-warnings: true

README.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# CapacitiveTouch Library
2+
3+
The CapacitiveTouch Library is designed to simplify the use of capacitive touch sensors on Arduino UNO-R4 boards (Minima and WiFi). This library hides the low-level hardware details (CTSU, DTC, interrupts, etc.) and provides a simple, user-friendly API for beginners and educational projects.
4+
5+
## Features
6+
- **Easy to Use API:**
7+
Initialize your sensor with just one constructor call and use simple methods to read sensor values and detect touches.
8+
- **Board Support:**
9+
Compatible with Arduino UNO-R4 Minima and UNO-R4 WiFi boards.
10+
- **Low-Level Abstraction:**
11+
All complex tasks (hardware setup, measurement control, interrupt management) are abstracted away so you can focus on your project.
12+
13+
## Installation
14+
1. Copy `CapacitiveTouch.h` and `CapacitiveTouch.cpp` into your Arduino libraries folder.
15+
2. Restart your Arduino IDE so it recognizes the new library.
16+
17+
## Compatible Pins
18+
19+
### Arduino UNO-R4 Minima
20+
| Arduino Pin | Touch Sensor Channel (TS#) | Channel Control Index (CHAC idx) | Channel Control Bit Mask (CHAC val) |
21+
|--------------|----------------------------|----------------------------------|-------------------------------------|
22+
| D0 | 9 | 1 | (1 << 1) |
23+
| D1 | 8 | 1 | (1 << 0) |
24+
| D2 | 34 | 4 | (1 << 2) |
25+
| D3 | 13 | 1 | (1 << 5) |
26+
| D8 | 11 | 1 | (1 << 3) |
27+
| D9 | 2 | 0 | (1 << 2) |
28+
| D11 | 10 | 1 | (1 << 2) |
29+
| D13 | 12 | 1 | (1 << 4) |
30+
| A1 (D15) | 21 | 2 | (1 << 5) |
31+
| A2 (D16) | 22 | 2 | (1 << 6) |
32+
| LOVE_BUTTON | 0 | 0 | (1 << 0) |
33+
34+
### Arduino UNO-R4 WiFi
35+
| Arduino Pin | Touch Sensor Channel (TS#) | Channel Control Index (CHAC idx) | Channel Control Bit Mask (CHAC val) |
36+
|--------------|----------------------------|----------------------------------|-------------------------------------|
37+
| D0 | 9 | 1 | (1 << 1) |
38+
| D1 | 8 | 1 | (1 << 0) |
39+
| D2 | 13 | 1 | (1 << 5) |
40+
| D3 | 34 | 4 | (1 << 2) |
41+
| D6 | 12 | 1 | (1 << 4) |
42+
| D8 | 11 | 1 | (1 << 3) |
43+
| D9 | 2 | 0 | (1 << 2) |
44+
| D11 | 7 | 0 | (1 << 7) |
45+
| D12 | 6 | 0 | (1 << 6) |
46+
| A1 (D15) | 21 | 2 | (1 << 5) |
47+
| A2 (D16) | 22 | 2 | (1 << 6) |
48+
| LOVE_BUTTON | 27 | 3 | (1 << 3) |
49+
50+
> **Note:** Only the above pins are supported. Other pins are not configured for capacitive touch sensing.
51+
52+
## Usage Example
53+
54+
```cpp
55+
#include "CapacitiveTouch.h"
56+
57+
// Instantiate a capacitive touch sensor using the LOVE_BUTTON macro.
58+
CapacitiveTouch ct = CapacitiveTouch(LOVE_BUTTON);
59+
60+
void setup() {
61+
Serial.begin(9600);
62+
ct.begin();
63+
ct.setThreshold(500); // Adjust threshold (lower values increase sensitivity)
64+
Serial.println("CapacitiveTouch Library: LOVE Button test");
65+
}
66+
67+
void loop() {
68+
int sensorValue = ct.read();
69+
Serial.print("Raw Value: ");
70+
Serial.println(sensorValue);
71+
72+
if (ct.isTouched()) {
73+
Serial.println("LOVE button touched!");
74+
}
75+
delay(100);
76+
}

examples/LoveButton/LoveButton.ino

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include "CapacitiveTouch.h"
2+
3+
// Create a CapacitiveTouch object for the LOVE button using the defined LOVE_BUTTON macro.
4+
CapacitiveTouch loveButton = CapacitiveTouch(1);
5+
6+
void setup() {
7+
Serial.begin(9600);
8+
// Initialize the LOVE button sensor.
9+
loveButton.begin();
10+
// Optionally adjust the threshold if needed.
11+
loveButton.setThreshold(5000);
12+
Serial.println("LOVE button sensor test started.");
13+
}
14+
15+
void loop() {
16+
// Retrieve the raw sensor reading.
17+
int sensorValue = loveButton.read();
18+
19+
// Print the raw value.
20+
Serial.print("Raw value: ");
21+
Serial.println(sensorValue);
22+
23+
// Check if the sensor is touched (raw value exceeds the threshold).
24+
if (loveButton.isTouched()) {
25+
Serial.println("D1 touched!");
26+
}
27+
28+
delay(100);
29+
}

library.properties

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=Arduino_CapacitiveTouchUNOR4
2+
version=1.2
3+
author=Cristian Dragomir
4+
maintainer=Cristian Dragomir
5+
sentence=Use touch sensitive pins on UNO-R4 Minima and UNO-R4 WiFi
6+
category=Signal Input/Output
7+
url=https://github.com/bcmi_labs/Arduino_CapacitiveTouchUNOR4
8+
architectures=renesas_uno
9+
includes=CapacitiveTouch.h

0 commit comments

Comments
 (0)