Arnov Sharma
Published © GPL3+

TTP23 Touchpad Switch

A simple setup for LED toggle via TouchPad sensor TTP223.

BeginnerProtip18 minutes1,791
TTP23 Touchpad Switch

Things used in this project

Hardware components

ttp223
×1
LED (generic)
LED (generic)
×1
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
×1
Arduino Nano R3
Arduino Nano R3
×1
UTSOURCE Electronic Parts
UTSOURCE Electronic Parts
everything above can be found here for a low price
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

sch

Code

code

C/C++
const int switchPin = 3;
const int ledPin = 2;

int state;
int lastState;
int ledState;

void setup() {
  pinMode(ledPin,OUTPUT);
  pinMode(switchPin,INPUT_PULLUP);
}
void loop(){
state = digitalRead(switchPin);
if (state != lastState){
  if (state==HIGH){
    if (ledState==HIGH) ledState= LOW;
    else ledState = HIGH;
  }
  lastState=state;
}
digitalWrite(ledPin,ledState);
delay(20);
}

Credits

Arnov Sharma
333 projects • 339 followers
Just your average MAKER
Contact

Comments

Please log in or sign up to comment.