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 electronic 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. Program of Control Led Blinking Using electronic Switch With 8051
/****************************************************** IDE :- Keil DEVELOPED BY:- FIRMWARE DEVELOPER (www.firmcodes.com) WHAT PROGRAM DO:- BLINKING OF LED CONTROLLED BY ELECTRONIC SWITCH ******************************************************/ #include<reg51.h> sbit switch1=P1^0; // pin P1.0 IS accessed as a variable name switch1 sfr led=0xa0; // port P2 IS accessed as a variable name led void main() { switch1=0; // make pin P1.0 as INPUT MODE while(1) { if(switch1==1) //check switch is pressed or not led=0xff; // led on else led=0x00; // led off } }
PROTEUS File for SIMULATION(Password Of RAR file is :-firmcodes.com)
________________________________________________________________________________________________________
2. Program of Two ELECTRONIC SWITCH one for LED other for 7 SEGMENT With 8051
****************************************************** www.firmcodes.com DEVELOPED BY:- FIRMWARE DEVELOPER WHAT PROGRAM DO:- TWO ELECTRONIC SWITCH ,ONE CONTROL LED BLINKING AND OTHER CONTROL COUNTING OF 7 SEGMENT ****************************************************** #include<reg51.h> sfr led=0xa0; // led at port 2 sfr seven_seg=0xb0; // seven segment at port 3 sbit switch1=P1^0; // switch1 at pin P1.0 sbit switch2=P1^1; // switch2 at pin P1.1 void delay() int data1[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; // data of common anode void main() { int i=0,j; switch1=switch2=0; while(1) { if(switch1==1) // switch 1 { led=0xff; // led on delay(); led=0x00; // led off delay(); } else if(switch2==1) // 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++); } *************************************************************************** End program Thank you for visiting our website www.firmcodes.com ***************************************************************************
PROTEUS File for SIMULATION(Password Of RAR file is :-firmcodes.com)
________________________________________________________________________________________________________
Content for the tab VIDEO