Capacitive Sensor not working


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:

#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”