View Single Post
  #4   Spotlight this post!  
Unread 24-01-2016, 18:37
TimTheGreat's Avatar
TimTheGreat TimTheGreat is offline
ArchdukeTim
FRC #1418 (Vae Victis)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2011
Location: Falls Church
Posts: 234
TimTheGreat has a spectacular aura aboutTimTheGreat has a spectacular aura aboutTimTheGreat has a spectacular aura about
Re: Running different functions at the same time?

The good (and bad) thing about motors is if you don't tell them what to do, they'll do the last thing they were told. This means if you forget to set a motor to 0 when you're done with it it will stay turned on. You can use this to your advantage

Code:
if state == 1:
    motor.set(1)
    state = 2
if state == 2:
    do_pneumatic_stuff()
    #because the motor hasn't been set to 0, it's still set to 1
    if pneumatic_stuff_done:
        state == 3
if state == 3
    motor.set(0) #Now we set it to 0 to stop it
__________________
There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.



2012 - Gracious Professionalism - Greater DC
2014 - Regional Finalist - Virginia | Industrial Design - Virginia | Regional Finalist - Greater DC
2015 - Innovation in Control - Greater DC
2016 - District Event Winner - VAHAY | Innovation in Control - VAHAY | District Event Winner - MDBET | Industrial Design - MDBET | District Champion - CHCMP | Innovation in Control - CHCMP
Reply With Quote