Q
qatar.engineer
Guest
hoi
Ik schrijf dit programma te lezen van de sensor en display output op deksel, maar als ik mijn geprogrammeerde PIC en maar in het circuit is ofwel altijd op of het is uitgeschakeld dus wat moet ik doen hier is mijn programma
# include <p18f4520.h>
# include <stdio.h>
# include <delays.h>
# pragma config WDT = OFF
void delay_ms (lange t);
/ / unsigned int count;
int count1;
void main (void)
(
TRISD = 0;
TRISC = 1; is input en output van de sensor is aangesloten
TRISA = 0;
/ / PORTC = 0;
/ / LATA = 0;
while (1)
(
/ / PORTBbits.RB0 = 0; / / portb0 is input
PORTDbits.RD0 = 0; PORTD is de output en input van de sensor
/ / LATC = 1; / / porta0 is output
Delay1KTCYx (1); / / wacht 1ms
/ / PORTBbits.RB0 = 1;
PORTDbits.RD0 = 1;
Delay1KTCYx (1); / / wacht 1ms
PORTDbits.RD0 = 0;
/ / PORTBbits.RB0 = 0;
while (LATC == 1)
(
/ / if (LATA == 0)
/ / Printf ( "ERROR \ n");
/ / else
/ / (
count1 ;
/ / PORTC = count1;
PORTA = 0xFF;
/ / printf ( "juiste \ n");
/ /)
while (LATC == 1)
(
if (LATC == 1)
(
count1 ;
/ / PORTC = count1;
PORTA = 0xFF;
/ / printf ( "juist weer \ n");
)
)
)
if (LATC == 0)
(
/ / PORTC = 0;
PORTA = 0x00;
/ / printf ( "einde \ n");
)
)
)
Ik schrijf dit programma te lezen van de sensor en display output op deksel, maar als ik mijn geprogrammeerde PIC en maar in het circuit is ofwel altijd op of het is uitgeschakeld dus wat moet ik doen hier is mijn programma
# include <p18f4520.h>
# include <stdio.h>
# include <delays.h>
# pragma config WDT = OFF
void delay_ms (lange t);
/ / unsigned int count;
int count1;
void main (void)
(
TRISD = 0;
TRISC = 1; is input en output van de sensor is aangesloten
TRISA = 0;
/ / PORTC = 0;
/ / LATA = 0;
while (1)
(
/ / PORTBbits.RB0 = 0; / / portb0 is input
PORTDbits.RD0 = 0; PORTD is de output en input van de sensor
/ / LATC = 1; / / porta0 is output
Delay1KTCYx (1); / / wacht 1ms
/ / PORTBbits.RB0 = 1;
PORTDbits.RD0 = 1;
Delay1KTCYx (1); / / wacht 1ms
PORTDbits.RD0 = 0;
/ / PORTBbits.RB0 = 0;
while (LATC == 1)
(
/ / if (LATA == 0)
/ / Printf ( "ERROR \ n");
/ / else
/ / (
count1 ;
/ / PORTC = count1;
PORTA = 0xFF;
/ / printf ( "juiste \ n");
/ /)
while (LATC == 1)
(
if (LATC == 1)
(
count1 ;
/ / PORTC = count1;
PORTA = 0xFF;
/ / printf ( "juist weer \ n");
)
)
)
if (LATC == 0)
(
/ / PORTC = 0;
PORTA = 0x00;
/ / printf ( "einde \ n");
)
)
)