1.
Project Summary:
This project is base on the capacitive touch sensor which is same as our android touchscreen phone’s screen. In this project we are using it just to get familiar with it and also know it working.
A
capacitive touch sensor is a sensor which creates a capacitor with plate and
skin of person who touch it. And our Arduino read’s that value from any digital
pin of Arduino board and convert that capacitance into a digital value.
Whenever someone touches a sensor than it gives a low out which can be read at
serial monitor Arduino board.
So let make it….
2. Component & tools required:
In
this project we would required the component and tools which are described
below.
·
Arduino board.
·
Arduino Software (IDE).
·
Capacitive sensor.
·
Green led 1.
·
Buzzer.
·
1K resisters 1.
·
Jumper wires.
·
Bread board
3. Connection:
In this project we would connect Arduino board with
the capacitive touch sensor and buzzer alarm to detect rather the sensor is touched
or not and according to that out would be see on the hard ware and the
software.
Table of
connection: -
S no.
|
Components Pin
|
Arduino Pins
|
1
|
Capacitive sensor VCC
|
5.v supply.
|
2.
|
Capacitive sensor GND
|
GND
|
3.
|
Capacitive sensor output
|
D2 pin
|
4.
|
Green Led.
|
D3 pin
|
5
|
Buzzer
|
D4 pin.
|
4. Follow
the following steps to perform this project:
Step 1: - Gather the entire components and make connection as show above. Open up the Arduino Software and open file in the folder name Alarm system with capacitive with_Arduino
Step 2: - Go to tools and check the right board and Com Port. If it doesn’t show up like this, than go to device manager and update the driver of Arduino on USB com device
Step 3: -
Uploading the program to Arduino board by clicking on the upload button which
is shown in the picture below. And check the result of you project.
After the code uploading you can check the
result in the Arduino Serial monitor and our hardware also.
5. Result:
If you have done everything correctly than you would have same results which are shown below.
5.1 Capacitive touch isn’t touched: -
When the capacitive touch sensor is not touched than buzzer remains silent and
Green Led glows, this means that Alarm is off. This result can be seen of
Hardware and software both.
Result of this process can be also seen
on the serial monitor of the Arduino software which is shown below.
5.2
Capacitive
sensor is touched: -
when capacitive touch sensor is touched than alarm becomes ON and which can be
seen an hardware where buzzer get high and starts buzzing and green led gets
off.
And in this condition we can see the result
on the serial monitor of Arduino software also,
as it is shown in the below image.
6. Project specification:
This
project is too simple to make and can be used at many different places if you
are creative enough to do so. And also we can understand the basic working of
the capacitive touch technology with help of this project.
Different project
in which it could be used are described below.
·
We can make it use in a
touch lock system in our drawer and cubbad.
7. Arduino code for Project:
burn the below given code int your Arduino board and enjoy.
//Alarm system with capacitive touch sensor
int LEDPin = 13; // LED on pin 13 which is Arduin board's led.
int capSensePin = 2; // Capacitive sensor on pin D2
int buzzer= 3; //buzzer on pin D3
int touchedCutoff = 60;
void setup()
{
Serial.begin(9600);
pinMode(LEDPin, OUTPUT);
digitalWrite(LEDPin, LOW);
}
void loop()
{
if (readCapacitivePin(capSensePin) > touchedCutoff) // If the capacitive sensor reads above a certain threshold,
// turn on the LED
{
digitalWrite(LEDPin, HIGH); //when capacitive sensor is not touch.
digitalWrite(buzzer,LOW);
Serial.println("Capacitive sensor is not touched");
}
else
{
digitalWrite(LEDPin, LOW); //when capacitive sensor is touch.
digitalWrite(buzzer,HIGH);
Serial.println("Capacitive sensor is touched");
}
if ( (millis() % 50) == 0) // Every 50 ms, print the value of the capacitive sensor
{
Serial.print("Capacitive Sensor on Pin 2 reads: ");
Serial.println(readCapacitivePin(capSensePin));
}
}
// readCapacitivePin
// Input: Arduino pin number
// Output: A number, from 0 to 17 expressing
// how much capacitance is on the pin
// When you touch the pin, or whatever you have
// attached to it, the number will get higher
// In order for this to work now,
// The pin should have a 1+Megaohm resistor pulling
// it up to +5v.
uint8_t readCapacitivePin(int pinToMeasure) //this part of the code
//convert the capacitive charging time into a digital value.
{
// This is how you declare a variable which
// will hold the PORT, PIN, and DDR registers
// on an AVR
volatile uint8_t* port;
volatile uint8_t* ddr;
volatile uint8_t* pin;
// Here we translate the input pin number from
// Arduino pin number to the AVR PORT, PIN, DDR,
// and which bit of those registers we care about.
byte bitmask;
if ((pinToMeasure >= 0) && (pinToMeasure <= 7)){
port = &PORTD;
ddr = &DDRD;
bitmask = 1 << pinToMeasure;
pin = &PIND;
}
if ((pinToMeasure > 7) && (pinToMeasure <= 13)){
port = &PORTB;
ddr = &DDRB;
bitmask = 1 << (pinToMeasure - 8);
pin = &PINB;
}
if ((pinToMeasure > 13) && (pinToMeasure <= 19)){
port = &PORTC;
ddr = &DDRC;
bitmask = 1 << (pinToMeasure - 13);
pin = &PINC;
}
// Discharge the pin first by setting it low and output
*port &= ~(bitmask);
*ddr |= bitmask;
delay(1);
// Make the pin an input WITHOUT the internal pull-up on
*ddr &= ~(bitmask);
// Now see how long the pin to get pulled up
int cycles = 16000;
for(int i = 0; i < cycles; i++){
if (*pin & bitmask){
cycles = i;
break;
}
}
// Discharge the pin again by setting it low and output
// It's important to leave the pins low if you want to
// be able to touch more than 1 sensor at a time - if
// the sensor is left pulled high, when you touch
// two sensors, your body will transfer the charge between
// sensors.
*port &= ~(bitmask);
*ddr |= bitmask;
return cycles;
}
if you like my post than please don't forget to share and follow. :)
and we you want to learn more about capacitive sensor than go to below link.
Thanks, l like you! l am wantysz, We have the capacitive touch digitizer manufacturer
ReplyDelete