Copy Paste Clip number :
 

Copy-Paste anything you want, then get it from anywhere.


Clip number :   XYZ
Direct URL :   https://www.heypasteit.com/clip/XYZ
Date :   2011-05-14 21:06:38 GMT
Download as file
void main(void)
{
	TRISA = 0b00000011;			/* Set RA0 and RA1 as input, all others output */
	TRISB = 0b00001100;			/* Set RB2 and RB3 as input, all others output */
	ADCON1 = 0b00001111;			/* Make outputs digital */
	INTCON3bits.INT1IP = 1;		/* Interrupts 0-3 high priority (INT0 fixed) */
	INTCON3bits.INT2IP = 1;
	INTCON2bits.INT3IP = 1;
	INTCONbits.INT0IF = INTCON3bits.INT1IF = INTCON3bits.INT2IF = INTCON3bits.INT3IF = 0;	/* Clear interrupt flags */
	PORTB = 0b00000000;																	/* Set PORTB low */
	flasherON = sequencerON = chaserON = emergencyON = 0;									/* Turn off patterns */
	
	while(1)
	{
		check_int();
		
		if(flasherON)
		{
			do
			{
				LED_1 = 1;				// Blink LED
				Delay10KTCYx(10);		
				LED_1 = 0;
				Delay10KTCYx(10);
				
				INTCONbits.INT0IF = INTCON3bits.INT1IF = INTCON3bits.INT2IF = INTCON3bits.INT3IF = 0;
				check_int();		// Check for interrupt flags
			}while(flasherON);
		}
		else if(sequencerON)
		{
			do
			{
				Delay10KTCYx(20);		// Move LED left to right
				LED_1 = 1;
				Delay10KTCYx(5);
				LED_1 = 0;
				LED_2 = 1;
				Delay10KTCYx(5);
				LED_2 = 0;
				LED_3 = 1;
				Delay10KTCYx(5);
				LED_3 = 0;
				LED_4 = 1;
				Delay10KTCYx(5);
				LED_4 = 0;
			
				INTCONbits.INT0IF = INTCON3bits.INT1IF = INTCON3bits.INT2IF = INTCON3bits.INT3IF = 0;
				check_int();		// Check for interrupt flags
			}while(sequencerON);
		}
		else if(chaserON)
		{
			do
			{
				Delay10KTCYx(20);		// Move LED left to right
				LED_1 = 1;
				Delay10KTCYx(2);
				LED_1 = 0;
				LED_2 = 1;	
				Delay10KTCYx(2);
				LED_2 = 0;
				LED_3 = 1;
				Delay10KTCYx(2);
				LED_3 = 0;
				LED_4 = 1;
				Delay10KTCYx(2);
				LED_4 = 0;
				LED_3 = 1;
				Delay10KTCYx(2);
				LED_3 = 0;
				LED_2 = 1;
				Delay10KTCYx(2);
				LED_2 = 0;
				LED_1 = 1;
				Delay10KTCYx(2);
				LED_1 = 0;
				Delay10KTCYx(10);
				
				INTCONbits.INT0IF = INTCON3bits.INT1IF = INTCON3bits.INT2IF = INTCON3bits.INT3IF = 0;
				check_int();		// Check for interrupt flags
			}while(chaserON);
		}
		else if(emergencyON)
		{
			do
			{
				Delay10KTCYx(20);		// Flash outer LEDs twice
				LED_1 = 1; 
				LED_4 = 1;
				Delay10KTCYx(2);
				LED_1 = 0; 
				LED_4 = 0;
				Delay10KTCYx(2);
				LED_1 = 1; 
				LED_4 = 1;
				Delay10KTCYx(2);
				LED_1 = 0; 
				LED_4 = 0;
				Delay10KTCYx(4);
				LED_2 = 1;		// Flash inner LEDs twice
				LED_3 = 1;			
				Delay10KTCYx(2);
				LED_2 = 0; 
				LED_3 = 0;
				Delay10KTCYx(2);
				LED_2 = 1; 
				LED_3 = 1;
				Delay10KTCYx(2);
				LED_2 = 0; 
				LED_3 = 0;
				Delay10KTCYx(4);
				
				INTCONbits.INT0IF = INTCON3bits.INT1IF = INTCON3bits.INT2IF = INTCON3bits.INT3IF = 0;
				check_int();		// Check for interrupt flags
			}while(emergencyON);
		}
	}
}
© 2021  HeyPasteIt.com  -  All rights reserved.