Arduino, Cpp.
reading is greater than the threshold: if (sensorReading >= threshold) { // Toggle the status of the ledPin: ledState = !ledState; // Update the LED pin itself: digitalWrite(ledPin, ledState); // Send the string "Knock!" back to the computer, followed by newline Serial.println("Knock!"); }