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 }
Text editor powered by tinymce.