Skip to content

Commit 0a1885d

Browse files
author
ShawnHymel
committed
Added example Arduino sketch
1 parent d31c28c commit 0a1885d

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
12-23-2013
3+
SparkFun Electronics 2013
4+
Shawn Hymel
5+
6+
This code is public domain but you buy me a beer if you use this
7+
and we meet someday (Beerware license).
8+
9+
Description:
10+
11+
This sketch shows how to use the SparkFun AT42QT1010 Breakout
12+
Board. If you touch the Capacitive Touch area on the breakout
13+
board, the LED attached to the Arduino will light up (in addition
14+
to the LED on the AT42QT1010 breakout board).
15+
16+
Simply connect power and ground to the breakout board,
17+
and the AT42QT1010 handles all the capacitive touch functions.
18+
By default, the board will light up the green LED when the pad
19+
is touched. A wire may also be connected from OUT on the
20+
breakout board to a digital input pin on an Arduino. This signal
21+
is normally LOW but goes HIGH on a touch event.
22+
23+
The "LED Enable" solder jumper may be de-soldered in order to
24+
control the LED directly from the LED pin. This is useful if you
25+
want to light up a button that the user needs to push.
26+
27+
Hardware connections:
28+
29+
Uno Pin AT42QT1010 Board Function
30+
31+
+5V VDD Power supply
32+
GND GND Ground
33+
2 OUT Capacitive touch event output
34+
*/
35+
36+
// Constants
37+
const int TOUCH_BUTTON_PIN = 2; // Input pin for touch events
38+
const int LED_PIN = 13; // Pin number for LED
39+
40+
// Global Variables
41+
int buttonState = 0; // Variable for reading button
42+
43+
void setup() {
44+
45+
// Configure button pin as input
46+
pinMode(TOUCH_BUTTON_PIN, INPUT);
47+
48+
// Configure LED pin as output
49+
pinMode(LED_PIN, OUTPUT);
50+
51+
}
52+
53+
void loop() {
54+
55+
// Read the state of the capacitive touch board
56+
buttonState = digitalRead(TOUCH_BUTTON_PIN);
57+
58+
// If a touch event occurs, turn on the LED
59+
if (buttonState == HIGH) {
60+
digitalWrite(LED_PIN, HIGH);
61+
} else {
62+
digitalWrite(LED_PIN, LOW);
63+
}
64+
}

Firmware/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* AT42QT1010_Arduino_Example - Simple sketch showing how to use the AT42QT1010 to detect a capacitive touch event

0 commit comments

Comments
 (0)