December 28, 2015

Badge Challenge Build Part 9

You can’t launch the nuke’s with out having two keys to turn, this post will look at the keys and buttons.

def SetLaunchKeyB(inputpin): global key_SW1 global key_SW2 if(GPIO.input(37)): key_SW2=time.time() else: key_SW2=0 if (GPIO.input(33))and(GPIO.input(37)): if (abs(key_SW1 - key_SW2) <0.2): Boom()

This is called by an IO interrupt, when a key event happens, we check if the input is high or low, if high then set key_SW1 to current time if it is low then we set key_SW1 to 0. If both keys set high, then we can check the time difference. This is the internal wiring, simple and ugly