Go to Post I'm sure there are many people out there who check their rep screen every 20 minutes in hope of positive reinforcement in a unique community, where they may not get positive reinforcement for sharing information in their home, school, or robotics program. - Eugenia Gabrielov [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
  #1   Spotlight this post!  
Unread 16-01-2006, 15:02
Windward's Avatar
Windward Windward is offline
Registered User
FRC #1452
Team Role: Programmer
 
Join Date: Nov 2005
Rookie Year: 2004
Location: So Cal
Posts: 88
Windward is an unknown quantity at this point
toggle switch

We were setting up a toggle switch so that when you press a button (p1_sw_trig) it activates a spike (relay1_fwd) and when you press the button again it deactivates it. I will also use this for other things in the programming code, such as a manual overide for the auto tracking.


int switch1, switch2, initVar, printCount, switch1Count, switch2Count;

switch1 = SWITCH1; // port1 trig
switch2 = SWITCH2; // port1 top

if(initVar !=1) // initialize variables
{
printCount = 0;
}

printf("switch1 = %d", switch1);
printf("switch2 = %d", switch2);

if(switch1 == 1) // if switch1 pressed
{
if(switch1Count != 1) // not forward, so set forward
{
switch1Count = 1;
}
else // forward, so set back
{
switch1Count = 0;
}
}

printCount++;
if(printCount > 100) // decreases amount of printfs
{
printf("switch1 = %d", switch1);
printf("switch1Count = %d", switch1Count);
printCount = 0;
}
if(switch1Count == 1)
{
relay1_fwd = 1;
switch1Count = 1;
if1 = 1;
}
if(switch1Count == 0)
{
relay1_rev = 1;
switch1Count = 2;
}
 


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
PRESSURE SWITCH Mr. Steve Pneumatics 20 01-12-2005 10:20
Toggle switch with pneumatic The yellowdart Programming 2 21-02-2005 14:08
Pneumatics on a toggle switch Idaman323 Programming 3 15-02-2005 18:42
LEDs in switch box. ZZII 527 Electrical 5 06-03-2004 19:39
3 way toggle switch programming LeadRiccardoT Programming 3 17-02-2003 02:02


All times are GMT -5. The time now is 10:54.

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