Chocolate Box with Touch Sensor and Arduino

Hi guys! Do you know what is a capacitive touch sensor?🧐

Introduction

Capacitive sensor deals with capacitance or in simple words capacitor. A capacitance is built between the sensor and the human body when we bring a human body near the sensor. A charge is induced and this charge is picked by the sensor and is translated as a button press. As we move our finger back from the sensor plate the capacitance is lost and circuit breaks. 

Video

This video will show you How to control A Chocolate Box with Touch Sensor and Arduino.

Hardware Preparation

This is the hardware connection and the components needed.

Untitled Sketch Bb
Figure 1 : Touch sensor connection.
Full Bb
Figure 2 : Hardware connection

Sample Code

#include <Servo.h>
Servo myservo1;
Servo myservo2;
int touchSensorPin = 2;
int touchSensorState = 0;
void setup() {
myservo1.attach(9);
myservo2.attach(10);
pinMode(touchSensorPin, INPUT);
}
void loop() {
if (digitalRead(touchSensorPin) == 1) {
myservo1.write(180);
delay(15);
while (1) {
myservo2.write(0);
delay(1000);
myservo2.write(180);
delay(1000);
if (digitalRead(touchSensorPin) == 1) {
myservo1.write(0);
delay(1000);
break;
}
}
}
else {
myservo1.write(0);
delay(15);
myservo2.write(180);
delay(1000);
}
}
view raw lovebox.ino hosted with ❤ by GitHub

References :

  1. Touch sensor with Arduino

Thank you

Thank you for reading this tutorial and we hope it helps your project development. If you have any technical inquiry, please post at Cytron Technical Forum.

Leave a Comment

Your email address will not be published.

Share this Tutorial

Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest
Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest

Latest Tutorial

Program micro:bit V2 Using MicroPython On Raspberry Pi
Basic Comparison Between MicroPython and Arduino
The Octolapse V0.4.1 With Raspberry Pi Camera
Getting Started With Node-RED Using Raspberry Pi
How Raspberry Pi Has Changed the World
Scroll to Top