def __init__(self): # Initialize pin select registers roboveroConfig() # enable IMU_EN pinMode(P1_0, OUTPUT) digitalWrite(P1_0, 0) self.accelerometer = Accelerometer() self.compass = Compass() self.gyrometer = Gyrometer()
def run(): # no need for roboveroConfig() heartbeatOff() pinMode(BTN, INPUT) pinMode(LED, OUTPUT) while True: digitalWrite(LED, digitalRead(BTN))
def run(): echo_pin = P0_5 trig_pin = P0_4 pinMode(trig_pin,OUTPUT) pinMode(echo_pin,INPUT) try: while True: print pulseIn(trig_pin, echo_pin, 9850)/58 # cm. Divide by 148 for in. sleep(.1) except: print "goodbye"
def run(): roboveroConfig() pinMode(LED, OUTPUT) heartbeatOff() # Initialize script myscript=Script([["GPIO_ClearValue", 3, 2000000], ["delay",10000000], ["GPIO_SetValue", 3, 2000000]]) print "script added" try: while True: raw_input("Press Enter to run script") print myscript.run() print "script done" # append to script myscript.append("delay",10000000) myscript.append("GPIO_ClearValue", 3, 2000000) myscript.append("delay",10000000) myscript.append("GPIO_SetValue",3, 2000000) except: heartbeatOn() print "goodbye"
def run(): # control the LED manually heartbeatOff() pinMode(LED, OUTPUT) # setup EINT0 on pin 2.10 PinCfg = PINSEL_CFG_Type() PinCfg.Funcnum = 1 PinCfg.OpenDrain = 0 PinCfg.Pinmode = 0 PinCfg.Pinnum = 10 PinCfg.Portnum = 2 PINSEL_ConfigPin(PinCfg.ptr) EXTI_Init() # register the callback registerCallback(IRQn_Type.EINT0_IRQn, EINT0Callback) # enable EINT0 NVIC_EnableIRQ(IRQn_Type.EINT0_IRQn) # the callback does everything from here while True: sleep(1)
def run(): # no need for roboveroConfig() pinMode(P1_27, OUTPUT) pinMode(P3_25, OUTPUT) pinMode(P4_29, OUTPUT) pinMode(P4_28, OUTPUT) delay=0.00001 try: while True: digitalWrite(P4_28, HIGH) digitalWrite(P1_27, LOW) digitalWrite(P3_25, LOW) digitalWrite(P4_29, LOW) time.sleep(delay) digitalWrite(P1_27, HIGH) digitalWrite(P3_25, LOW) digitalWrite(P4_29, LOW) digitalWrite(P4_28, LOW) time.sleep(delay) digitalWrite(P3_25, HIGH) digitalWrite(P1_27, LOW) digitalWrite(P4_29, LOW) digitalWrite(P4_28, LOW) time.sleep(delay) digitalWrite(P4_29, HIGH) digitalWrite(P1_27, LOW) digitalWrite(P3_25, LOW) digitalWrite(P4_28, LOW) time.sleep(delay) print("ticktickticktick") except: digitalWrite(P1_27, LOW) digitalWrite(P3_25, LOW) digitalWrite(P4_29, LOW) digitalWrite(P4_28, LOW) exit("goodbye")
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) # control the LED manually heartbeatOff() pinMode(LED, OUTPUT) # setup EINT0 on pin 2.10 PinCfg = PINSEL_CFG_Type() PinCfg.Funcnum = 1 PinCfg.OpenDrain = 0 PinCfg.Pinmode = 0 PinCfg.Pinnum = 10 PinCfg.Portnum = 2 PINSEL_ConfigPin(PinCfg.ptr) EXTI_Init() # register the callback registerCallback(IRQn_Type.EINT0_IRQn, EINT0Callback) # enable EINT0
"""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))
def IMUInit(): """ Enable IMU by pulling IMU_EN low """ pinMode(P1_0, OUTPUT) digitalWrite(P1_0, 0) print 'init'
def IMUReset(): """ Reset IMU by pulling IMU_EN high and then low """ pinMode(P1_0, OUTPUT) digitalWrite(P1_0, 1) digitalWrite(P1_0, 0)
connect the stepper wires are orange, red, blue, yellow for CW motion. """ from robovero.arduino import pinMode, digitalWrite, P1_27, P3_25, P4_29, P4_28 from robovero.arduino import OUTPUT, LOW, HIGH import time __author__ = "Danny Chan" __email__ = "*****@*****.**" __copyright__ = "Copyright 2012, Gumstix Inc." __license__ = "BSD 2-Clause" __version__ = "0.1" # no need for roboveroConfig() pinMode(P1_27, OUTPUT) pinMode(P3_25, OUTPUT) pinMode(P4_29, OUTPUT) pinMode(P4_28, OUTPUT) delay = 0.00001 try: while True: digitalWrite(P4_28, HIGH) digitalWrite(P1_27, LOW) digitalWrite(P3_25, LOW) digitalWrite(P4_29, LOW) time.sleep(delay) digitalWrite(P1_27, HIGH) digitalWrite(P3_25, LOW)
def IMUInit(): #Enable IMU by pulling IMU_EN lowx pinMode(P1_0, OUTPUT) digitalWrite(P1_0, 0)
connect the stepper wires are orange, red, blue, yellow for CW motion. """ from robovero.arduino import pinMode, digitalWrite, P1_27, P3_25, P4_29, P4_28 from robovero.arduino import OUTPUT, LOW, HIGH import time __author__ = "Danny Chan" __email__ = "*****@*****.**" __copyright__ = "Copyright 2012, Gumstix Inc." __license__ = "BSD 2-Clause" __version__ = "0.1" # no need for roboveroConfig() pinMode(P1_27, OUTPUT) pinMode(P3_25, OUTPUT) pinMode(P4_29, OUTPUT) pinMode(P4_28, OUTPUT) delay=0.00001 try: while True: digitalWrite(P4_28, HIGH) digitalWrite(P1_27, LOW) digitalWrite(P3_25, LOW) digitalWrite(P4_29, LOW) time.sleep(delay) digitalWrite(P1_27, HIGH) digitalWrite(P3_25, LOW)
def IMUReset(): #Reset IMU by pulling IMU_EN high and then lowp pinMode(P1_0, OUTPUT) digitalWrite(P1_0, 1) digitalWrite(P1_0, 0)
def IMUInit(): """ Enable IMU by pulling IMU_EN low """ pinMode(P1_0, OUTPUT) digitalWrite(P1_0, 0)