fork download
  1. #include<xc.h>
  2. __PROG_CONFIG(1,0x3FE4);
  3. __PROG_CONFIG(2,0x1FEF);
  4.  
  5. #define _XTAL_FREQ 16000000
  6. #define LED_apas_scurt RB1
  7. #define LED_apas_mediu RB2
  8. #define LED_apas_lung RB3
  9.  
  10. void init_uC(void);
  11.  
  12. void main(void)
  13. {
  14. init_uC();
  15. while(1)
  16. {
  17. if(RB0==0)
  18. {
  19. __delay_ms(800);
  20. if(RB0==1) LED_apas_scurt=1;
  21. else
  22. {
  23. __delay_ms(1000);
  24. if(RB0==1) LED_apas_mediu=1;
  25. else LED_apas_lung=1;
  26.  
  27. }
  28. __delay_ms(1000);
  29. PORTB=0b00000000;
  30. }
  31. }
  32. }
  33. void init_uC(void)
  34. {
  35. OSCCON=0x7B;
  36. TRISB=0b00000001;
  37. PORTB=0b00000000;
  38. ANSELB=0b00000000;
  39. }
Success #stdin #stdout 0.02s 25912KB
stdin
Standard input is empty
stdout
#include<xc.h>
__PROG_CONFIG(1,0x3FE4);
__PROG_CONFIG(2,0x1FEF);

#define _XTAL_FREQ 16000000
#define LED_apas_scurt RB1
#define LED_apas_mediu RB2
#define LED_apas_lung RB3

void init_uC(void);

void main(void)
{
	init_uC();
	while(1)
	{
		if(RB0==0) 
		{
			__delay_ms(800);
			if(RB0==1) LED_apas_scurt=1;
			else
			{
				__delay_ms(1000);
				if(RB0==1) LED_apas_mediu=1;
				else LED_apas_lung=1;
				
			}
			__delay_ms(1000);
			PORTB=0b00000000;
		}
	}
}
void init_uC(void)
{
	OSCCON=0x7B;
	TRISB=0b00000001;
	PORTB=0b00000000;
	ANSELB=0b00000000;
}