This sample code shows you how to program the touch sensor to sense your touch on the flower core/stamen. Turn on the Serial Monitor to observe the touch sensing.

#define TOUCHPIN   6

void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(115200);
  // make the pushbutton's pin an input:
  pinMode(TOUCHPIN, INPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input pin:
  int touchState = digitalRead(TOUCHPIN);
  // print out the state of the button:
  Serial.println(touchState);
  delay(10);        // delay in between reads for stability
}

This guide was first published on Mar 29, 2022. It was last updated on 2022-03-29 22:32:49 -0400.

This page (Sample Code for Touch) was last updated on Mar 29, 2022.

Text editor powered by tinymce.