You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/hardware/02.hero/boards/uno-r4-wifi/tutorials/touch/content.md
+21-24Lines changed: 21 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
---
2
-
title: Uno R4 Capacitor Tutorial
2
+
title: Uno R4 Capacitive-Touch Tutorial.
3
3
description: Learn to use the built-in capacitive sensing capabilities of the Arduino® Uno R4.
4
4
tags: [Arduino, Capacitive Sensing, Uno R4]
5
5
author: Pedro Lima
@@ -19,17 +19,16 @@ Here's the process:
19
19
3. This changes the capacitance of the system
20
20
4. The microcontroller measures this change and determines if it's significant enough to register as a "touch"
21
21
22
-
23
-
24
22
## Using Capacitive Sensing on the Uno R4
25
23
26
24
The Uno R4 features a Capacitive Touch Sensing Unit (CTSU) that allows you to use certain pins as capacitive touch inputs. To utilize these capabilities, you can use the [Arduino_CapacitiveTouch library](https://github.com/arduino-libraries/Arduino_CapacitiveTouch).
27
25
28
26
### Compatible Pins
29
27
30
-
For both the Uno R4 WiFi and Minima, the compatible pins for capacitive touch are listed in the [Arduino_CapacitiveTouch library documentation](https://github.com/arduino-libraries/Arduino_CapacitiveTouch?tab=readme-ov-file#compatible-pins).
28
+
For both the Uno R4 WiFi and Minima boards, the compatible pins for capacitive touch are listed in the [Arduino_CapacitiveTouch library documentation](https://github.com/arduino-libraries/Arduino_CapacitiveTouch?tab=readme-ov-file#compatible-pins).
31
29
32
30
**Arduino® UNO-R4 Minima:**
31
+
33
32
| Arduino Pin | Touch Sensor Channel (TS#) | Channel Control Index (CHAC idx) | Channel Control Bit Mask (CHAC val) |
@@ -63,29 +63,26 @@ For both the Uno R4 WiFi and Minima, the compatible pins for capacitive touch ar
63
63
64
64
### Library Functions
65
65
66
-
The Arduino_CapacitiveTouch library provides several functions to work with capacitive touch inputs:
66
+
The **Arduino_CapacitiveTouch** library provides several functions to work with capacitive touch inputs:
67
67
68
-
-**```CapacitiveTouch(uint8_t pin)```** Constructs a capacitive touch sensor for the given pin.
69
-
-**```bool begin()```** Initializes the sensor and configures the pin and hardware.
70
-
-**```int read()```** Reads the raw sensor value and returns it.
71
-
-**```bool isTouched()```** Checks if the sensor is touched based on the threshold.
72
-
-**```void setThreshold(int threshold)```** Sets the detection threshold for touch sensitivity.
73
-
-**```int getThreshold()```** Retrieves the current detection threshold.
68
+
-**`CapacitiveTouch(uint8_t pin)`** Constructs a capacitive touch sensor for the given pin.
69
+
-**`bool begin()`** Initializes the sensor and configures the pin and hardware.
70
+
-**`int read()`** Reads the raw sensor value and returns it.
71
+
-**`bool isTouched()`** Checks if the sensor is touched based on the threshold.
72
+
-**`void setThreshold(int threshold)`** Sets the detection threshold for touch sensitivity.
73
+
-**`int getThreshold()`** Retrieves the current detection threshold.
74
74
75
75
For more detailed usage and examples, refer to the [CapacitiveSensor library documentation](https://docs.arduino.cc/libraries/capacitivesensor/).
76
76
77
77
## Example Code
78
78
79
-
Here's a simple example to get you started with capacitive sensing on the Uno R4.
80
-
For this example we are connecting a single piece of any conductive material to the pin ```D0``` on the Board.
79
+
Here's a simple example to get you started with capacitive sensing on the Uno R4. For this example, we are connecting a single piece of any conductive material to the pin `D0` on the Board.
81
80
82
81

83
82
84
-
**Note:**
85
-
You will first need to install the library [Arduino_CapacitiveTouch](https://docs.arduino.cc/libraries/capacitivesensor/):
***__Note:__ You will first need to install the library [Arduino_CapacitiveTouch](https://docs.arduino.cc/libraries/capacitivesensor/). To do so, open `Arduino IDE: Library Manager` → `Search "Arduino_CapacitiveTouch"` within _Manage Libraries_ option → `Install` .***
Now that you understand the basics, here are some project ideas:
121
117
122
-
**Touch-Controlled Night Light -** Create a lamp that turns on/off with a touch
123
-
**Capacitive Touch Piano -** Use multiple pins to create touch-sensitive keys
124
-
**Smart Home Controller -** Touch different areas to control various devices
125
-
**Interactive Art Installation -** Create touch-responsive visual or audio effects
118
+
Now that you have learned the basics, here are some fun and interesting project ideas:
119
+
120
+
-**Touch-Controlled Night Light -** Create a lamp that turns on/off with a touch
121
+
-**Capacitive Touch Piano -** Use multiple pins to create touch-sensitive keys
122
+
-**Smart Home Controller -** Touch different areas to control various devices
123
+
-**Interactive Art Installation -** Create touch-responsive visual or audio effects
126
124
127
125
## Conclusion
128
126
129
-
The built-in capacitive sensing capabilities of the Arduino® Uno R4 provide an excellent way to add touch inputs to your projects. By leveraging the Arduino_CapacitiveTouch library, you can easily integrate touch-sensitive features, enhancing the interactivity and functionality of your designs. Whether you're building a simple touch interface or a more complex interactive system, the Uno R4's capacitive sensing features offer a versatile and user-friendly solution.
130
-
Remember to experiment with threshold values and consider the environment where your project will be used, as factors like humidity and nearby electronics can affect sensitivity. With practice, you'll develop an intuitive understanding of how to tune these sensors for optimal performance in your specific applications.
127
+
Capacitive sensing on the Arduino UNO R4 lets you add intuitive touch controls with minimal hardware, simply pair the board with the `Arduino_CapacitiveTouch` library. Tune the detection threshold for your environment (humidity, nearby electronics, etc.), and you can quickly scale from a single touch button to richer, multi-point interfaces.
0 commit comments