required some help in modification of the program
Discussion in "Project Addition or Changes" started by arejar21 Mar 27, 2009.
Fri Mar 27 2009, 01:33 am
hi..
i'm currently doing my final project by using a TX-RX module..
i want to do a modification for my programming part but i don't know where should i put it in that coding.
this is my coding for the project:
this program is working when the pic is given an 0 input to the port a. this is happens because the receiver give 0 signal (meanings 0V voltage)
when port a is 0, 1st motor will turn on.
and after a few delays, if the receiver still give 0 input to the PIC, the second motor will turn on for 6 sec. then, both of the motor will stop running. this the situation for my program.
now, i'm afraid i need to do a modification on that program. supposedly, the 1st motor should turn off if the receiver give 1 input to the PIC. but, when i'm testing the hardware, the motor keep continuing turn on even though the receiver give 1 input to the PIC. it shouldn't turn on when the PIC receiver 1 input from the receiver.
i want the 1st motor turn off when the PIC receive 1( digital data =1) input from the receiver,and also for the 2nd motor. it will turn off if the pic receive 1 input. But, i don't know where and what should i put in the program for that situation.Can someone help me??
i'm currently doing my final project by using a TX-RX module..
i want to do a modification for my programming part but i don't know where should i put it in that coding.
this is my coding for the project:
/* * Project name: Anti-Napping System */Description MCU: PIC16F876A Oscillator: HS, 04.0000 MHz */ unsigned short cnt; void main(){ char oldstate = 0; TRISB = 0xff; TRISC = 0x00; trisa= 0x00; portc=0; cnt=0; do { if (Button(&PORTB, 1, 1, 1)) oldstate = 1; if (oldstate && Button(&PORTB, 1, 1, 0)) { portc = ~PORTC; cnt++; oldstate = 0; delay_ms(6000); // motor slow on for 6 sec portc=0; // 1st motor is turn on } if (cnt==1){ delay_ms(2000); //delay before turn on the 2nd motor porta=0xff; delay_ms(6000); //6sec delay porta=0; cnt=0; } } while(1); // endless loop }
this program is working when the pic is given an 0 input to the port a. this is happens because the receiver give 0 signal (meanings 0V voltage)
when port a is 0, 1st motor will turn on.
and after a few delays, if the receiver still give 0 input to the PIC, the second motor will turn on for 6 sec. then, both of the motor will stop running. this the situation for my program.
now, i'm afraid i need to do a modification on that program. supposedly, the 1st motor should turn off if the receiver give 1 input to the PIC. but, when i'm testing the hardware, the motor keep continuing turn on even though the receiver give 1 input to the PIC. it shouldn't turn on when the PIC receiver 1 input from the receiver.
i want the 1st motor turn off when the PIC receive 1( digital data =1) input from the receiver,and also for the 2nd motor. it will turn off if the pic receive 1 input. But, i don't know where and what should i put in the program for that situation.Can someone help me??
[ Edited Fri Mar 27 2009, 10:37 pm ]
Fri Mar 27 2009, 11:03 pm
i am not able to understand your problem..
try this..
hope your problem get solved. and you said signal is applied to port A whereas your code does not check for signal on porta, rather you are checking portb. please see if your explanation is correct.
try this..
if (cnt==1) //change this //to if(cnt==2)
hope your problem get solved. and you said signal is applied to port A whereas your code does not check for signal on porta, rather you are checking portb. please see if your explanation is correct.
Powered by e107 Forum System