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:
  // make the pushbutton's pin an 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:
  delay(10);        // delay in between reads for stability

This guide was first published on Mar 29, 2022. It was last updated on Mar 08, 2024.

This page (Sample Code for Touch) was last updated on Mar 08, 2024.

Text editor powered by tinymce.