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.
- 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).
- 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 LED AND SWITCH INTERFACING WITH ATMEGA16
________________________________________________________________________________________________________
2. CIRCUIT DIAGRAM OF TWO SWITCH , LED, 7 SEGMENT AND TWO SWITCH INTERFACING WITH ATMEGA16
________________________________________________________________________________________________________
1. Program of Control Led Blinking Using Switch Interfacing With ATmega16
/****************************************************** www.firmcodes.com DEVELOPED BY:- FIRMWARE DEVELOPER WHAT PROGRAM DO:- CONTROL LED BLINK USING SWITCH ******************************************************/ #include<avr/io.h> #include<util/delay.h> void main() { unsigned int i; DDRB=0X00; DDRA=0XFF; while(1) { i=PINB & 0X01; if(i==1) { PORTA=0XFF; _delay_ms(100); PORTA=0X00; _delay_ms(100); } } }
PROTEUS File for SIMULATION(Password Of RAR file is :-firmcodes.com)
________________________________________________________________________________________________________
2. Program of 2 switch one for led other for 7 segment With ATMEGA16
/****************************************************** www.firmcodes.com DEVELOPED BY:- FIRMWARE DEVELOPER WHAT PROGRAM DO:- TWO SWITCH, ONE CONTROL LED AND OTHER CONTROL SWITCH ******************************************************/ #include<avr/io.h> #include<util/delay.h> void main() { int data1[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; unsigned int i=0,p,q,j; DDRB=0X00; DDRD=0X00; DDRA=0XFF; DDRC=0XFF; PORTB=0X00; while(1) { p=PINB & 0X01; q=PIND & 0X01; if(p==1) { PORTA=0XFF; _delay_ms(100); PORTA=0X00; _delay_ms(100); } else if(q==1) { if(i==10) i=0; PORTC=data1[i]; _delay_ms(400); i++; } } }
PROTEUS File for SIMULATION(Password Of RAR file is :-firmcodes.com)
________________________________________________________________________________________________________
Content for the tab VIDEO