Spread the love
___________________________________________________________________________________________________
- What is electronics switch? – A switch is an electrical component that can break an electrical circuit, interrupting the current or diverting it from one conductor to another. There are two main state of switch “open” and “close”. And each switch has a mechanism that is “toggle” or “momentary”. Toggle mean flip switch for continuous “on” or “off”. Momentary mean push-for “on” or push-for “off”.
- Types of switch –
- Operation – We can interface a switch to microcontroller by two way as shown in above image.
- 1. Connecting switch by Vcc and MCU (SW1) – detecting switch by logic ‘1’ at port pin when switch is pressed (here pin 0 of port 0).
- 2. Connecting switch by GND and MCU (SW2) – detecting switch by logic ‘0’ at port pin when switch is pressed (here pin 1 of port 0).
- Applications- Different types of switches are used according to different parameters. Like computer keyboard and mobile keypad are use momentary SPST switches. Home Appliances use SPDT switches.
1. CIRCUIT DIAGRAM OF 8 LED, ONE SWITCH INTERFACING WITH PIC18F458 CONTROLLER
______________________________________________________________________________________________________
2. CIRCUIT DIAGRAM OF 8 LED , 7 SEGMENT AND TWO SWITCH INTERFACING WITH PIC18F458 MICROCONTROLLER
1. Program of Control Led Blinking Using Switch Interfacing With PIC18F458 microcontroller
/****************************************************** www.firmcodes.com DEVELOPED BY:- FIRMWARE DEVELOPER WHAT PROGRAM DO:- 7 SEGMENT COUNT 0 TO 9 ATTACHED WITH ATMEHA16 ******************************************************/ /* header file used in this program is already included in software microC pro for pic*/ #define led PORTC // data of lcd at port c void main() { int i=0,j,switch1; TRISC=0X00; TRISB=0xff; PORTB=0XFF; while(1) { switch1=portb & 0x01; if(switch1==0) // switch 1 { led=0xff; // led on } else { led=0x00; // led off } } }
PROTEUS File for SIMULATION(Password Of RAR file is :-firmcodes.com)
______________________________________________________________________________________________________
2. Program of in which led is control by one switch and 7 segment is controlled by other switch interfacing With PIC18F458 microcontroller
/****************************************************** www.firmcodes.com DEVELOPED BY:- FIRMWARE DEVELOPER WHAT PROGRAM DO:- TWO SWITCH ONE CONTROL LED BLINKING AND OTHER CONTROL 7 SEGMENT ******************************************************/ /* header file used in this program is already included in software microC pro for pic*/ #define led PORTC // data of lcd at port c #define seven_seg PORTD // data of 7 SEGMENT at port D void delay(); void main() { int data1[]={ 0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f }; // data of common cathode int i=0,j,switch1,switch2; TRISC=TRISD=0X00; PORTC=0X00; TRISB=0xff; PORTB=0XFF; while(1) { switch1=portb & 0x01; switch2=portb & 0x02; if(switch1==0) // switch 1 { led=0xff; // led on delay(); led=0x00; // led off delay(); } else if(switch2==0) // switch 2 { if(i==10) i=0; seven_seg=data1[i]; for(j=0;j<50;j++) delay(); i++; } } } void delay() { int i; for(i=0;i<3000;i++); }
PROTEUS File for SIMULATION(Password Of RAR file is :-firmcodes.com)
______________________________________________________________________________________________________
Content for the tab VIDEO