Go Down

Topic: Capacitive Sensor not working (Read 406 times) previous topic - next topic


Jun 14, 2019, 04:46 pm Last Edit: Jun 14, 2019, 04:57 pm by HunkyMcHunkins

I've been using this code on The Things Uno to light up a LED when I touch a coin and it has worked perfectly fine:
Code: [Select]
#include <CapacitiveSensor.h>

#include <CapacitiveSensor.h>
CapacitiveSensor cap = CapacitiveSensor(4,2);

const int ledPin = 10;
const int threshold = 80;

void setup() {
  pinMode(ledPin, OUTPUT);

void loop() {
  long sensorValue = cap.capacitiveSensor(30);


  if (sensorValue > threshold) {
    digitalWrite(ledPin, HIGH);
  else {
    digitalWrite(ledPin, LOW);



But when I'm switching board to the Rev2 and changed board and port on the IDE I'm not getting the same response. Is there anything I don't know that I should?

Thank you for your help!


Bump. The values on the Serial monitor shows "-2"

Go Up