Hi I have a problem I am doing a program which changes the patterns. The following is the program.
Now can anyone help me I want the program that when I press a switch I want it to continue it`s respective pattern until another switch is pressed
and then does the pattern according to that switch. an so on and so forth
any help is appreciated thanks a lot the PIC I am programming in 16F84A
Rich (BB code):
#include <pic.h>
#include <htc.h>
#include "delay.c"
#include "delay.h"
#define XTAL_FREQ 4MHZ
__CONFIG (WDTDIS & XT & UNPROTECT & PWRTEN);
void init(void)
{
// port directions: 1=input, 0=output
PORTA=0xFF;
//PORTA=0x00;
PORTB=0x00;
//PORTB=0xFF
TRISA=0xFF;
//TRISA=0x00;
TRISB=0x00;
//TRISB=0xFF;
}
void main(void)
{
init();
while (1)
{
int check = PORTA;
if(check == 0b00001)
{
goto start;
}
if(check == 0b00010)
{
goto start1;
}
if(check == 0b00100)
{
goto start2;
}
if(check == 0b01000)
{
goto start3;
}
start:
do
{
PORTB=0b11000000;
DelayMs(100);
for(int x=0; x<5; x++)
{
PORTB=PORTB>>1;
DelayMs(300);
}
PORTB=0b00000011;
DelayMs(100);
for (int y=0; y<5; y++)
{
PORTB=PORTB<<1;
DelayMs(300);
}
}
while(check!=0b00010 && check!=0b00100 && check!=0b01000);
start1:
do
{
PORTB=0b00000001;
DelayMs(200);
PORTB=0b00000011;
DelayMs(200);
PORTB=0b00000111;
DelayMs(200);
PORTB=0b00001111;
DelayMs(200);
PORTB=0b00011111;
DelayMs(200);
PORTB=0b00111111;
DelayMs(200);
PORTB=0b01111111;
DelayMs(200);
PORTB=0b11111111;
DelayMs(200);
}
while(check!=0b00001 && check!=0b00100 && check!=0b01000);
start2:
do
{
PORTB=rand();
DelayMs(300);
}
while(check!=0b00001 && check!=0b00010 && check!=0b01000);
start3:
do
{
for(int x=0; x<256; x++)
{
PORTB=x;
DelayMs(30);
}
}
while(check!=0b00001 && check!=0b00010 && check!=0b00100);
}
}
and then does the pattern according to that switch. an so on and so forth
any help is appreciated thanks a lot the PIC I am programming in 16F84A