Manpreet1604
Junior Member level 1
Code:
#include <xc.h>
#pragma config FOSC = INTOSCIO
#pragma config WDTE = ON
#pragma config PWRTE = OFF
#pragma config MCLRE = OFF
#pragma config CP = OFF
#pragma config CPD = OFF
#pragma config BOREN = OFF
#pragma config IESO = OFF
#pragma config FCMEN = OFF
#define LED1 GPIObits.GP4 // Pin No. 3
#define LED2 GPIObits.GP5 // Pin No. 2
#define LED3 GPIObits.GP0 // Pin No. 7
#define LED4 GPIObits.GP1 // Pin No. 6
#define INPUT GPIObits.GP2 // Pin No. 5
void delay_1ms();
unsigned char count = 0;
void main (void){
ANSEL = 0x00; // turn off analog inputs
ADCON0 = 0x00; //Turn off ADC
CMCON0 = 0x07; //Turn off Comparators
VRCON = 0x00; //Turn off Voltage Reference
OSCCON = 0b01110000; // internal oscillator, 8 MHz
OPTION_REG = 0b00001111;//Prescalar assigned to WDT
TRISIO = 0x04;//make GP2 as input and rest as output
LED1=0; // set initial state of pin
LED2=0;
LED3=0;
LED4=0;
while(1){
SLEEP(); // Sleep mode
LED2 = 1; // After wake-up the LED is turned on
LED1 = 1;
delay_1ms();
LED2 = 0;
LED1 = 0;
if (count == 6){
LED3 = 1;
delay_1ms();
LED3 = 0;
count = 0 ;
}
if (INPUT == 1){
LED4=1;
LED1=1;
LED2=1;
LED3=0;
CLRWDT();
}
}
}
void delay_1ms(){
TMR0 = 0 ;
while (TMR0 < 200);
count = count++ ;
}
hello everyone i am working with pic 12F683 and trying to learn WDT mode in this code iam able to turn on my LED 1,2 and 3 at desire time but unable to execute "
if (INPUT == 1){
LED4=1;
LED1=1;
LED2=1;
LED3=0;
CLRWDT();
}
"
I want to read the Input pin when Led1 and Led 2 goes high hardware is simple I have a pic 12f683 with 4 led and INPUT iam using jumper wire any help will be appreciated thanks.