Society of Robots - Robot Forum
Software => Software => Topic started by: kim3sarmy on April 11, 2010, 06:07:07 PM
-
someone plez help me to solve my coding..
i'm working on line follower robot using pic 16f877a,relay mtr driver,12V DC motor...
i use port b = RB1 to RB3 for 3 set of IR sensor
port c = RC1 & RC2 for PWM
port a = RA to RA4
somebody plez check my coding
-
What kind of errors are you getting? What exactly isn't working?
Having a full program and having nothing to look for really makes people NOT want to look through the program. However, if we know what's wrong, then we can specifically look for things that could be wrong.
-
What is your code doing wrong or not doing?
Please add comments to every line so we know what you think the line of code should do.
i use port b = RB1 to RB3 for 3 set of IR sensor
port c = RC1 & RC2 for PWM
port a = RA to RA4
Put this info in the code as comments with info on what each port is used for.
I assume that RB1-3 are inputs so why are you testing all those ports?
if (RB2==0)if(RB3==1)if(RB4==1)if(RB5==1)if (RC3==1)if(RC4==1)
What are the other ports for? State what these inputs are and what combination is required for the action.
What are the config bits set for? See the HiTech manual (look at the file pic1687x.h in the HiTech install directory) and the Special Features section of the PIC data sheet.
You can also set these in the code or from MPLAB menu Configure\Configuration Bits.
Does the code compile?????
It did not for me as there is an extra '}' and code line.
Did you run this code in the MPLAB simulator????
I do 98% of debugging in the simulator.
-
port b are used for input from sensor array...the problem is i can't compile this code using mplab
-
the problem is i can't compile this code using mplab
Yes I stated that and gave told you why.
You have mismatched curly braces, a } without a { and a return 0; that should not be there.
Fix those and the code will build.
Hint: In the MPLAB editor, if you place the cursor in front of a } the matching { will be also highlighted. If a { or } does not highlight than there isn't a matching { or }.
-
I hate when I get my curly brackets get messed up. You always get a TON of errors because you forgot one simple character. :P
-
Hi,
A simple way of keeping your brackets sorted is to simply allways place them in pairs
Eg.
SomeFunction(void)
{}
Then you separate the curls (and if like me, indent them).
SomeFunction(void)
{
}
Then you're ready to write the contents
SomeFunction(void)
{
// Programming in C is allways ugly...
// But there's no reason to trip ones own feet
C + Programming != Beauty
}
Now you'll never have missing or leftover brackets (unless you cut and paste too rigorously).