def EINT0Callback(): """Callback function for EINT0. """ while not digitalRead(BTN): sleep(0) print "%s don't touch that!" % choice(responses) state = digitalRead(LED) digitalWrite(LED, state ^ 1) EXTI_ClearEXTIFlag(0)
def run(): # no need for roboveroConfig() heartbeatOff() pinMode(BTN, INPUT) pinMode(LED, OUTPUT) while True: digitalWrite(LED, digitalRead(BTN))
"""Control the LED with the pushbutton using the Arduino API. """ from robovero.arduino import pinMode, digitalWrite, digitalRead, BTN, LED from robovero.arduino import INPUT, OUTPUT from robovero.extras import heartbeatOff __author__ = "Neil MacMunn" __email__ = "*****@*****.**" __copyright__ = "Copyright 2010, Gumstix Inc." __license__ = "BSD 2-Clause" __version__ = "0.1" # no need for roboveroConfig() heartbeatOff() pinMode(BTN, INPUT) pinMode(LED, OUTPUT) while True: digitalWrite(LED, digitalRead(BTN))