Capacitive touch sensor interfacing with PIC Microcontroller and Mikro C
In this tutorial we will learn how to interface capacitive touch sensor with microcontroller. Here I am use PIC16F877A microcontroller and LM16x2 Lcd display. The Lcd display show the status of LED.
You can watch the video or read the written tutorial below.
Picture of Capacitive Touch Sensor.
Here is am use latch technique for LED switching.
Mikro C Code for this projects:
Click the download for source code :
You can watch the video or read the written tutorial below.
Picture of Capacitive Touch Sensor.
Pin Configuration
- VCC : Positive Supply (2V to 5.5V)
- I/O
- GND : Ground supply
Capavitive Touch Sensor is a input device. It is use for switch as like push button. Capacitive touch sensor is relies on figer pressure for interaction. When a figure touch on sensor surface then the senor output is active high. While the finger relies on touch surface the output is active low.
Circuit schematic:
.
Here is am use latch technique for LED switching.
Latch circuits output has tow stable state
- High state
- Low state
Mikro C Code for this projects:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Lcd module connections | |
sbit LCD_RS at RB0_bit; | |
sbit LCD_EN at RB1_bit; | |
sbit LCD_D4 at RB2_bit; | |
sbit LCD_D5 at RB3_bit; | |
sbit LCD_D6 at RB4_bit; | |
sbit LCD_D7 at RB5_bit; | |
sbit LCD_RS_Direction at TRISB0_bit; | |
sbit LCD_EN_Direction at TRISB1_bit; | |
sbit LCD_D4_Direction at TRISB2_bit; | |
sbit LCD_D5_Direction at TRISB3_bit; | |
sbit LCD_D6_Direction at TRISB4_bit; | |
sbit LCD_D7_Direction at TRISB5_bit; | |
// End lcd module connnections | |
# define SW PORTD.RD7 // switch is connect to RD7 | |
int i = 0; | |
void main() { | |
TRISC = 0X00; // PORTC in output | |
TRISD = 0X80; // RD7 is input | |
PORTC = 0X00; // clear PORTC | |
PORTD = 0X00; // Clear PORTD | |
Lcd_Init(); // Initialize Lcd module | |
Lcd_Cmd(_LCD_CURSOR_OFF); // Lcd cursor off | |
Lcd_Cmd(_LCD_CLEAR); // Led clear | |
Lcd_Out(1,3,"DEVELOPED BY"); // Lcd show "DEVELOPED BY" | |
Lcd_Out(2,1,"MINA TECHNOLOGY"); // Lcd show "MINA TECHNOLOGY" | |
delay_ms(2000); // 2s delay | |
Lcd_Cmd(_LCD_CLEAR); // Lcd clear | |
Lcd_Out(1,2,"TOUCH SENSOR"); // Lcd show "LATCH" | |
Lcd_Out(2,1,"LED:"); // Lcd show "LED:" | |
while(1){ // Endless loop | |
if(SW==1){ | |
while(SW==1); // wait for SW release | |
i++; // Increase value | |
} | |
PORTC = i; | |
if(i==2)i=0; | |
if(i==0){ | |
Lcd_Out(2,5,"OFF"); | |
} | |
else{ | |
Lcd_Out(2,5,"ON "); | |
} | |
} | |
} |
Click the download for source code :
![]() |
download |
No comments