Issue with hardware for Touchy-Feely Lamp (Project 13)

Hello! We have followed the hardware schematic and code for the Touchy-Feely Lamp, and have not been able to turn on the LED nor read a different sensor value when using the suggested setup. We have exchanged all of our hardware in case we were working with a faulty piece, but this did not help. We also tried putting different thresholds into the code ranging from 1-10,000.

In trying to figure out what was wrong, we unplugged the wire that is connected to pin 2 from where it was connected to the 1 Mohm resistor. When we touched the end of this wire, the circuit worked as expected.

We have attached our a picture of our original circuit (made with Nano Every) and code. Please help us figure out why it is not working as it should according to the project instructions.

//Import a library from the Arduino folder
#include <CapacitiveSensor.h>
//Select the two pins that will act as a capacitor
CapacitiveSensor capSensor = CapacitiveSensor(4,2);
//Insert the minimum value provided by the sensor to detect the touch
int threshold = 1;
const int ledPin = 12;

void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
}

void loop() {
  //Read the sensor value
  long sensorValue = capSensor.capacitiveSensor(30);
  Serial.println(sensorValue);
  //Touch detected
  if (sensorValue > threshold) {
    //Turn on the led
    digitalWrite(ledPin, HIGH);
  }
  //Touch undetected
  else {
    //Turn off the led
    digitalWrite(ledPin, LOW);
  }
  //delay(10);
}

Is the LED wired with anode toward pin 12 and cathode toward ground? Try putting Serial.println("LED ON"); statements to ensure your sketch made it into that condition.

You seem to be using a "Nano Every" board. This board does not have the same pin out as a "Nano Classic" board. Also unlike the classic the every is a 3V3 processor.

Is this tutorial written for a "Nano Every" or a "Nano Classic"?
I suspect the latter, because the +3V3 output is on the fourth pin down from the top right and you seem to have connected the wire to the LED to the first or second wire down from the top right. Other pins could be different as well.

It is also not a very good or reliable project even using the correct board.

Yes, the LED is wired in this way, and it turns on when we connect it directly to 5V.

Most of the schematics that we used showed the project built using an Arduino Uno. We made sure to connect the pins to corresponding pins (digital input vs. digital output), and there is no direct power source applied. Only ground.

Post deleted by author

The LED should turn on when your code tells it to turn on. Verify all your connections.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.