void setup() {
volatile char *dir_F = 0x30; //Direction_of_Por_F
*dir_F = 0x01;
volatile char *dir_K = 0x107; //Direction_of_Port_K
*dir_K = 0x00;
}
void loop() {
volatile long i,j;
volatile char *out_F = 0x31; //Output_reg_of_Port_F
volatile char *in_K = 0x106; //Output_reg_of_Port_K
int count;
while(1)
{
if((*in_K & 0x01) == 0x01)
{
count++;
for(i=0; i<100000; i++);
}
//Duty_Cycle = 10%
if(count%2)
{
*out_F = 1;
for(i=0; i<45; i++);
*out_F = 0;
for(i=0; i<405; i++);
}
//Duty_Cycle = 100%
else
{
*out_F = 1;
for(i=0; i<450; i++);
*out_F = 0;
for(i=0; i<0; i++);
}
}
/*while(1)
{
for(j=0; j<45000; j++)
{
*out_F = 1;
for(i=0; i<j; i++);
*out_F = 0;
for(i=0; i<450000-j; i++);
}
}*/
}