hi im making a c program for the 68hc11 and to out put flashing ect ect on 6 lights on a O/I board i need to use a while loop to keep my lights flashing but i need program to continue on
heres my code
Code:
#include <stdio.h> /*standard i/o functions*/
#include <stdlib.h>
#include <math.h>
#include <iof1.h>
void main()
{
int choice,actizone;
do{
choice = menu(); /* Calls the menu and returns the users choice */
switch(choice)
{
case 1: /* Disarm the alarm */
{
arm();
break;
}
case 2: /* Arm the alarm */
{
break;
}
case 3: /* Exit */
{
exit(1);
break;
}
}
}while(1);
}
menu()
{
int choice, i;
printf("\n ===========================================");
printf("\n ----=====| Burgalar Alarm System |=====----");
printf("\n ================++++++++++++===============");
printf("\n 1. Arm Alarm");
printf("\n 2. Disarm Alarm");
printf("\n 3. Exit");
printf("\n -------------------------------------------");
printf("\n\n Please input your choice from the menu :> ");
scanf("%d", &choice);
printf("\n");
for(i=0;i<1;i++)
{
if(choice < 1 | choice > 4) // if the menu choice is invalid the program will ask the user to re input it.
{
printf("\nInvalid choice please re enter :> ");
scanf("%d", &choice);
i--;
}
}
return choice;
}
int arm(int argc, char *argv)
{
unsigned char mask, port;
unsigned int run,i;
unsigned int counters[6] = {0};
PORTG = 63;
DDRG = 0xff; //set port to output
run = 1;
while (run)
{
mask = 1; //reset mask to one before each iteration
for (i = 0; i < 6; i++)
{
if ((counters[i] == 500) && (port & mask))
{
PORTG ^= mask;
counters[i] = 0;
}
counters[i]++;
mask <<=1; //check next bit
}
}
printf("\n");
return 0;
}
the arm function makes the lights blink but i need them to stay blinking and not to keep my program in a infinate loop sooo i can select other things from the menu ect ect . Any ideas how i can do this
thankyou