naveen.kumar
Newbie level 4
- Joined
- Jul 3, 2013
- Messages
- 5
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 37
hello guys,
i am using pic18f4520 and iam making RA4 , RA5 ,RE0 and RE1 as input and i have connected pull up resistor as well but except RA4 all others are going inside the loop even though it is not grounded.
this is my program.....please help me out...
i am using pic18f4520 and iam making RA4 , RA5 ,RE0 and RE1 as input and i have connected pull up resistor as well but except RA4 all others are going inside the loop even though it is not grounded.
this is my program.....please help me out...
Code:
#include<p18f4520.h>
//#include"sutures_gloves_testing.h"
#pragma config OSC = HS //INTOSC_EC
#pragma config PWRT = OFF
#pragma config BOREN = OFF
#pragma config MCLRE = ON
#pragma config PBADEN = OFF
#pragma config LVP = OFF
#pragma config WDT = OFF //,DEBUG=OFF
#define LED1 (LATBbits.LATB3)
#define LED2 (LATBbits.LATB2)
#define LED3 (LATCbits.LATC5)
#define LED4 (LATCbits.LATC4)
#define SWITCH_1 (PORTAbits.RA4)
#define SWITCH_2 (PORTAbits.RA5)
#define SWITCH_3 (PORTEbits.RE0)
#define SWITCH_4 (PORTEbits.RE1)
#define Actuator_1 (LATAbits.LATA0)
#define Actuator_2 (LATAbits.LATA1)
#define Actuator_3 (LATAbits.LATA2)
#define Actuator_4 (LATAbits.LATA3)
#define Solenoid_1 (LATCbits.LATC2)
void All_init(void);
void main()
{
All_init();
Actuator_1 = 1;
Actuator_2 = 1;
Actuator_3 = 1;
Actuator_4 = 1;
while(1)
{
if(SWITCH_1 == 0)
{
Actuator_1 = 0;
}
if(SWITCH_2 == 0)
{
Actuator_2 = 0;
}
if(SWITCH_3 == 0)
{
Actuator_3 = 0;
}
if(SWITCH_4 == 0)
{
Actuator_4 = 0;
}
//Actuator_2 = 0;
}
}
void All_init()
{
TRISBbits.RB3 = 0;
TRISBbits.RB2 = 0;
TRISCbits.RC5 = 0;
TRISCbits.RC4 = 0;
TRISCbits.RC2 = 0;
TRISAbits.RA0 = 0;
TRISAbits.RA1 = 0;
TRISAbits.RA2 = 0;
TRISAbits.RA3 = 0;
TRISAbits.RA4 = 1;
TRISAbits.TRISA5 = 1;
TRISEbits.RE0 = 1;
TRISEbits.RE1 = 1;
}
Last edited by a moderator: