Go to Post If it were not about winning, it would not be called a competition - but FRC is much more than winning a competition. - JaneYoung [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

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 03-02-2016, 15:40
Arhowk's Avatar
Arhowk Arhowk is offline
FiM CSA
AKA: Jake Niman
FRC #1684 (The Chimeras) (5460 Mentor)
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Lapeer
Posts: 542
Arhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to behold
Re: Toggling Between Two buttons

Code:
if button.pressed():
    if !buttonWasPressed:
         buttonWasPressed = True
         motorSet = 1 - motorSet
else:
         buttonWasPressed = False

motor.set(motorSet)
python pseudocode
__________________
FRC Team 1684 - Head Programmer (2013-2016)
FRC Team 5460 - Programming Mentor (2015-2016)

FIRST in Michigan - Technical Crew (2015-continuing)
  #2   Spotlight this post!  
Unread 03-02-2016, 15:58
T3_1565 T3_1565 is offline
Registered User
AKA: Twitch Drive Designer
FRC #1360
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2005
Location: Burlington, Ontario
Posts: 855
T3_1565 has a brilliant futureT3_1565 has a brilliant futureT3_1565 has a brilliant futureT3_1565 has a brilliant futureT3_1565 has a brilliant futureT3_1565 has a brilliant futureT3_1565 has a brilliant futureT3_1565 has a brilliant futureT3_1565 has a brilliant futureT3_1565 has a brilliant futureT3_1565 has a brilliant future
Send a message via MSN to T3_1565
Re: Toggling Between Two buttons

Quote:
Originally Posted by Arhowk View Post
Code:
if button.pressed():
    if !buttonWasPressed:
         buttonWasPressed = True
         motorSet = 1 - motorSet
else:
         buttonWasPressed = False

motor.set(motorSet)
python pseudocode
That doesn't seem like what he is asking for.

I'm not a programmer at all but I think a variable is the correct way to deal with your request.

if Button A is pressed then set variable "X" to 1.
if Button B is pressed then set variable "X" to 2.
if "X" = 1 then Motor runs one way
if "X" = 2 then motor runs the other way

Again. Not a programmer. Just how your request sounds in my head.
  #3   Spotlight this post!  
Unread 03-02-2016, 16:11
GreyingJay GreyingJay is offline
Robonut
AKA: Mr. Lam
FRC #2706 (Merge Robotics)
Team Role: Mentor
 
Join Date: Mar 2015
Rookie Year: 2015
Location: Ottawa, Canada
Posts: 766
GreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond repute
Re: Toggling Between Two buttons

Quote:
Originally Posted by T3_1565 View Post
That doesn't seem like what he is asking for.

I'm not a programmer at all but I think a variable is the correct way to deal with your request.

if Button A is pressed then set variable "X" to 1.
if Button B is pressed then set variable "X" to 2.
if "X" = 1 then Motor runs one way
if "X" = 2 then motor runs the other way

Again. Not a programmer. Just how your request sounds in my head.
This is correct.

Note that as it stands once one of these two buttons is pressed and the motor turns on, there is no way to turn it off again.
Closed Thread


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


All times are GMT -5. The time now is 14:55.

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