Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

help me in my program

Status
Not open for further replies.

qatar.engineer

Junior Member level 1
Joined
Nov 9, 2006
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,452
portbbits.rb0

hi
i write this program to read from sensor and display output on lid but when i programed my pic and but it in the circuit it is either always on or it is off so what should i do here is my program
#include <p18f4520.h>
#include <stdio.h>
#include <delays.h>
#pragma config WDT = OFF
void delay_ms(long t);
//unsigned int count;
int count1;
void main (void)
{
TRISD=0;
TRISC=1; is input and output from sensor is connected to it
TRISA=0;
//PORTC=0;
//LATA=0;
while(1)
{
//PORTBbits.RB0= 0; //portb0 is input
PORTDbits.RD0=0; portd is output and intput to sensor
//LATC=1; //porta0 is output
Delay1KTCYx(1); //wait for 1ms
//PORTBbits.RB0 =1;
PORTDbits.RD0=1;
Delay1KTCYx(1); //wait for 1ms
PORTDbits.RD0=0;
//PORTBbits.RB0 =0;
while(LATC==1)
{
//if(LATA==0)
// printf("error\n");

//else
//{
count1++;
// PORTC=count1;
PORTA=0xFF;
//printf("correct\n");
//}

while(LATC==1)
{
if(LATC==1)
{
count1++;
// PORTC=count1;
PORTA=0xFF;
//printf("correct again\n");

}
}
}
if(LATC==0)
{
//PORTC=0;
PORTA=0x00;
//printf("end\n");
}
}
}
 

p18f4520.h sensor program

i didn't got you? what thing is "always on or off"
 

p18f4520.h program

the leds is always on or off
 

p18f4520.h

There are too many Ambiguities in your program
First of mention which compiler are u using

and how are u getting data of interrupts from sensor
 

trisa vs lata

i am using the c18 comiler for mplab with picstrat and i do not get you when you said
how are u getting data of interrupts from sensor
 

porta and lata in the pic

Can u send me C18 Compiler from microchip

i need that compiler can u
 

latc c18

C18 is a free compiler provided by microchip . download from their website.
 

p18f4520

qatar.engineer said:
hi
i write this program to read from sensor and display output on lid but when i programed my pic and but it in the circuit it is either always on or it is off so what should i do here is my program
#include <p18f4520.h>
#include <stdio.h>
#include <delays.h>
#pragma config WDT = OFF
void delay_ms(long t);
//unsigned int count;
int count1;
void main (void)
{
TRISD=0;
TRISC=1; is input and output from sensor is connected to it
TRISA=0;
//PORTC=0;
//LATA=0;
while(1)
{
//PORTBbits.RB0= 0; //portb0 is input
PORTDbits.RD0=0; portd is output and intput to sensor
//LATC=1; //porta0 is output
Delay1KTCYx(1); //wait for 1ms
//PORTBbits.RB0 =1;
PORTDbits.RD0=1;
Delay1KTCYx(1); //wait for 1ms
PORTDbits.RD0=0;
//PORTBbits.RB0 =0;
while(LATC==1)
{
//if(LATA==0)
// printf("error\n");

//else
//{
count1++;
// PORTC=count1;
PORTA=0xFF;
//printf("correct\n");
//}

while(LATC==1)
{
if(LATC==1)
{
count1++;
// PORTC=count1;
PORTA=0xFF;
//printf("correct again\n");

}
}
}
if(LATC==0)
{
//PORTC=0;
PORTA=0x00;
//printf("end\n");
}
}
}

Have you put the pull up resistor?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top