bit oldstate1,count1;
int i;
int beep();
int privacy_state();
int privacy_state1();
int privacy[] = {1,0,0,0,0,0,0,0}; // privacy byte code for shift register
void beep()
{
Delay_ms(50); // initial delay
PORTD |= (0x01<<0); // BEEP ON
Delay_ms(200); // cutoff delay
PORTD &=~(0x01<<0); // BEEP OFF
}
void privacy_state()
{
for(i=0;i<=7;i++)
{
if (privacy[i]==1)
{
beep();
PORTA|=(0x01<<3); // data on
delay_ms(1);
}
if (privacy[i]==0)
{
PORTA&=~(0x01<<3); // data off
delay_ms(1);
}
PORTA |= (0x01<<1); // clk on
delay_ms(1);
PORTA &=~(0x01<<1); // clk off
delay_ms(1);
}
delay_ms(1);
PORTA |= (0x01<<2); // str on
delay_ms(1);
PORTA &=~(0x01<<2); // str off
delay_ms(1);
}
void privacy_state1()
{
for(i=0;i<=7;i++)
{
if (privacy[i]==1)
{
PORTA&=~(0x01<<3); // data off
delay_ms(1);
}
if (privacy[i]==0)
{
PORTA|=(0x01<<3); // data on
delay_ms(1);
}
PORTA |= (0x01<<1); // clk on
delay_ms(1);
PORTA &=~(0x01<<1); // clk off
delay_ms(1);
}
delay_ms(1);
PORTA |= (0x01<<2); // str on
delay_ms(1);
PORTA &=~(0x01<<2); // str off
delay_ms(1);
}
void main()
{
DDA0_BIT = 1; // DATA
DDA1_BIT = 1; // CLK
DDA2_BIT = 1; // STR
DDC6_BIT = 1; // DND LED
DDD0_BIT = 1; // BEEP OUT
PORTD4_BIT = 1; // DND SW
oldstate1 = 0;
do
{
//=============================== PRIVACY =====================================
{
if (Button(&PIND, 4, 1, 1))
{
oldstate1 = 1;
}
if (oldstate1 && Button(&PIND, 4, 1, 0))
{
privacy_state();
count1++;
}
if (count1==1)
{
privacy_state1();
}
}
//=============================================================================
}
while (1) ;
}