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

BLTouch Installation for Ender 3 with 32-bit V4.2.2 Board
Pick and Send Random Meal’s Option and Locations through Telegram Bot Using Grove WiFi 8266 on micro:bit
DIY Automated Vacuum Cleaner Using REKA:BIT With Micro:bit
Rainbow Spark in Mini House using Maker Uno.
TinyML on Arduino using Edge Impulse
Tutorials of Cytron Technologies Scroll to Top