View Single Post
  #11   Spotlight this post!  
Unread 05-02-2004, 07:31
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,544
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: A few questions on programming the Control System

Quote:
Originally Posted by rdsideresistanc
Keep in mind that im used to C-based languages...i've not done much programming in C....someone verify my code maybe?
you need to pass relayfwd and relayrev as pointers so that the modifications you make don't get "thrown out" when you exit the function.

I'm also not sure what the purpose of cyl_count is. Since you increment it each time the button is pressed, and reset each time it isn't pressed, it will only hold the value of 0 or 1. You could make the code much simpler by changing if (cyl_count == 1) to if (button) and removing the code before that.

Based on the sound of the variable name (cylinder count?), it seems that you may want to keep track of how many times you activated a cylinder. If you want to do that, remove the else {cyl_count = 0} part and change the if statement like I said above.

However, you only then would have the count of how many times total cylinders had been activated. You could pass cyl_count as a pointer again and have multiple variables for multiple cylinders.