|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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 |
|
|
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 |