——————————— updated on Nov 10————————————

After I’ve decided to go with touch sensor, I find a very interesting video online, which teaches me how to build a captive touch sensor myself! I’ll have a try!

If this goes wrong, I then will buy one online☟

https://www.amazon.com/gp/product/B00HFQEFWQ/ref=ox_sc_act_title_1?smid=A30QSGOJR8LMXA&psc=1

https://www.youtube.com/watch?v=pTSBXSCFBPs

——————————— updated on Nov 11————————————

Mark my first-ever ban—all because I returned the equipment late🥲.

截屏2024-11-13 下午8.45.29.png

I first tried having the code just like what is taught in the tutorial video.

#include <CapacitiveSensor.h>

CapacitiveSensor capSensor = CapacitiveSensor(4, A0);

int threshold1 = 1000;

const int ledPin1 = 5;

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

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

  Serial.print("Sensor Value: ");
  Serial.println(sensorValue);

  if (sensorValue > threshold1) {
    digitalWrite(ledPin1, HIGH);
  } else {
    digitalWrite(ledPin1, LOW);
  }
}

Because I am using nano33 lot, which is a little bit different from the microcontroller in the video, I changed the input and output pin a little bit.

When I am trying to touch the wire…

Nothing happened!!! At all!!!😡

I thought maybe the resistor made the current very small so the change might not be that obvious… So, I take out the resistor between pin4 and pinA0.

The moment I pulled out the resistor, magic happened—the light turned on! ✨💡😲

IMG_5BDC8ABAD3B7-1.jpeg

Even though at that moment, pin 2 and A0 were completely disconnected.