-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
53 lines (51 loc) · 810 Bytes
/
main.c
File metadata and controls
53 lines (51 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* passwordlockRECEIVER.c
*
* Created: 7/28/2022 9:14:02 PM
* Author : Muhammad Umar
*/
#include <avr/io.h>
#define F_CPU 1000000UL
#include<util/delay.h>
int main(void)
{
DDRD&=~(1<<PD0);
DDRA=0x00;
DDRB = 0xFF;
DDRE = 0b111;
UBRR0H=0x00;
UBRR0L=0x05;
UCSR0B|=(1<<RXEN0);
UCSR0C=(1<<USBS0)|(3<<UCSZ00);
char og_pass[4]={3,3,6,6};
int index =0;
unsigned char receiveData;
while (1)
{
receiveData=0;
while(!(UCSR0A&(1<<RXC0)))
{
if ((PINA&1)==1)
{
PORTB=0;
PORTE = 0b000;
_delay_ms(100);
PORTE = 0b001;
PORTE = 0b000;
index=0;
}
}
receiveData=UDR0;
if (receiveData==og_pass[index])
{
index++;
}
if (index==4)
{
PORTB = 1;
PORTE = 0b001;
_delay_ms(100);
PORTE = 0b000;
}
}
}