View Single Post
  #6   Spotlight this post!  
Unread 18-02-2008, 10:05
The Lucas's Avatar
The Lucas The Lucas is offline
CaMOElot, it is a silly place
AKA: My First Name is really "The" (or Brian)
FRC #0365 (The Miracle Workerz); FRC#1495 (AGR); FRC#4342 (Demon)
Team Role: Mentor
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Dela-Where?
Posts: 1,564
The Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond repute
Send a message via AIM to The Lucas
Re: Please help with our IR code, we are so confused

Quote:
Originally Posted by rjn View Post
Code:
void Autonomous(void)
{
int move, othermove;

//printf("Time=%lu", Get_Time( ));

if ((rc_dig_in01 + rc_dig_in02 + rc_dig_in03 + rc_dig_in04) > 1)
{
rc_dig_in01 = rc_dig_in02 = rc_dig_in03 = rc_dig_in04 = 0;
}
I am pretty sure you cant assign digital outputs (rc_dig_in0x) to zero. Digital inputs are not variables, they are alias to input ports on the microcontroller and I am pretty sure if you set them as input, you cant write that register. So what is probably happening is all digital inputs are 1 (and not getting zerod) and move is being set to 1 (since that is first in else if block). Move if ((rc_dig_in01 + rc_dig_in02 + rc_dig_in03 + rc_dig_in04) > 1) {} to the first statement in the "move setting" else if block. Also you IR sensor is probably not hooked up correctly if you are getting all 1s.

Also it would be better if you declared move as static (static int move) and removed othermove. A static int never gets destroyed so it will keep its value from one loop to the other.
__________________
Electrical & Programming Mentor ---Team #365 "The Miracle Workerz"
Programming Mentor ---Team #4342 "Demon Robotics"
Founding Mentor --- Team #1495 Avon Grove High School
2007 CMP Chairman's Award - Thanks to all MOE members (and others) past and present who made it a reality.
Robot Inspector
"I don't think I'm ever more ''aware'' than I am right after I burn my thumb with a soldering iron"

Last edited by The Lucas : 18-02-2008 at 10:07.