View Single Post
  #6   Spotlight this post!  
Unread 06-02-2008, 20:12
Laaba 80 Laaba 80 is offline
Registered User
AKA: Joey
FRC #1714 (MORE Robotics)
Team Role: Alumni
 
Join Date: Dec 2007
Rookie Year: 2001
Location: San Jose, CA
Posts: 495
Laaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond repute
Re: I am going crazy

Wow, yours seems kind of confusing. Another way of doing it which in my opinion is easier is

unsigned char motorup = TRUE;
unsigned char motordown = TRUE;

if (rc_dig_in01 == 1) //If the limit switch at the top is pressed
{
motorup = FALSE;
}
else
{
motorup = TRUE;
}
if (rc_dig_in02 == 1) //Limit switch at bottom
{
motordown = FALSE;
}
else
{
motordown = TRUE;
}
if (p1_sw_trig == TRUE && motorup == TRUE)
{
pwm01 = 200; //Assuming that a # higher that 127 goes up
}
if (p1_sw_top == TRUE && motordown == TRUE)
{
pwm01 = 50; //Assuming lower # goes down
}
else
{
pwm01 = 127;
}

This is how I like to do it. If you think another way is easier go for that. it is all about how you feel comfortable using code. Also I just made up the values and pwm numbers use whatever your motors and sensors are plugged into. Also im sorry about the font. I pressed a button and it changed the font and im not sure how to put it back to normal
Joey
__________________
Driving Record - 75-43-8
Coaching Record - 92-65