Go to Post We want to go out and build something right away. But it is better to think a little bit first. - ChrisH [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Spotlight this post!  
Unread 11-02-2007, 01:20
Ianuser Ianuser is offline
Registered User
FRC #0570
 
Join Date: Feb 2007
Location: new york
Posts: 64
Ianuser is an unknown quantity at this point
Re: How do I program this sensor?

This is what I have now:

Code:
void Default_Routine(void)
{
 	int count = 0;
	int now;
	int last;
	now = last;
	rc_dig_in04 = now;
blah blah blah..map joysticks..

Code:
 /***************
                  * Sensor Code *
                  ***************/
 
 	if((pwm03 < 125) || (pwm03 > 129))
 	{
 		if((now == 1) && (last == 0)) //If sensor, which connects to Dig In/Out port 4, goes off...
		{
			count++; //Number of times tape passes through the sensor.
			Switch1_LED = 1; //Switch01 goes on when the tape passes the sensor.
		}
		else
		{
			Switch1_LED = 0;
		}
	
	
		if(count == 8) 
		{
			Relay2_green = 0;
			Relay2_red = 0;
			pwm03 = 127; //Motor stops when it retreats to ground level.
			count = 0;
		}
		else if(count == 7) 
		{
			Relay2_green = 0;
			Relay2_red = 1;
			pwm03 = 127; //Motor stops when it retreats to 1st level.
		}
		else if(count == 6) 
		{
			Relay2_green = 0;
			Relay2_red = 1;
			pwm03 = 127; //Motor stops when it retreats to 2nd level.
		}
		else if(count == 5) 
		{
			Relay2_green = 0;
			Relay2_red = 1;
			//pwm03 does not equal 127 because it must pass the tape in order to go beneath the top level.
		}
		else if(count == 4)
		{
			Relay2_green = 1;
			Relay2_red = 1;
			pwm03 = 127; //Motor stops when it reaches top level.
		}
		else if(count == 3)
		{
			Relay2_green = 1;
			Relay2_red = 0;
			pwm03 = 127; //Motor stops when it reaches 2nd level.
		}
		else if(count == 2)
		{
			Relay2_green = 1;
			Relay2_red = 0;
			pwm03 = 127; //Motor stops when it reaches 1st level.
		}
		//if count == 1 then that just means that it passed through the first piece of tape which will be used to show that it is in full DOWN position.
	}
So I have yet to make the switch statement, but I made some changes. Do you understand yet what I am trying to do with the forklift Kevin? (Any other thoughts also) Thank you guys so much. You're saving my team of 5.
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Vex line follower sensor kit program jbill30 Programming 5 12-05-2006 14:43
What's happening to this program??? Weightmn General Forum 22 04-04-2005 15:40
TI Pressure Sensor this year? kmcclary Pneumatics 1 20-01-2005 20:53
This board is quiet-- so how bout this election?!?!? archiver 2000 19 24-06-2002 00:23
How do you connect optical sensor? archiver 2001 1 23-06-2002 23:05


All times are GMT -5. The time now is 04:44.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi