本文整理汇总了Python中PiStorms.PiStorms.led方法的典型用法代码示例。如果您正苦于以下问题:Python PiStorms.led方法的具体用法?Python PiStorms.led怎么用?Python PiStorms.led使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PiStorms.PiStorms
的用法示例。
在下文中一共展示了PiStorms.led方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PiStorms
# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import led [as 别名]
psm = PiStorms() # PiStorms object
exit = False # break loop
while (not exit):
light = psm.BBS1.lightSensorNXT(True)
# 520
error = 540 - light #if within 40 on edge, if negative on line, if positive in white
# psm.BBM1.setSpeedSync(30)
# if (abs(error) < 20): #on edge
# psm.BBM1.setSpeedSync(30)
# psm.led(1,0,255,0) #green
if (error < 0): #on line, turn to right, left wheel accelerate
psm.BBM1.setSpeed(25)
psm.BBM2.setSpeed(-50)
psm.led(1,0,0,255)#blue
elif (error > 0): #on white, turn to left, right wheel accelerate
psm.BBM2.setSpeed(25)
psm.BBM1.setSpeed(-50)
psm.led(1,255,0,0)#Red
sleep(0.1)
if (psm.isKeyPressed()): #exit
psm.BBM1.brakeSync()
psm.led(1,0,0,0)
psm.screen.clearScreen()
psm.screen.termPrintln("")
psm.screen.termPrintln("Exiting to menu")
sleep(0.5)
exit = True
示例2: sleep
# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import led [as 别名]
print 'f.set()'
sleep(0.1)
psm.led(1, 0, 0, 0)
if __name__ == "__main__":
entered_house = Event()
found_bomb = Event()
got_victim = Event()
f_thread = Thread(target=follow, args=(entered_house, found_bomb, got_victim))
f_thread.start()
s_thread = Thread(target=search, args=(entered_house, found_bomb, got_victim))
s_thread.start()
while not exit:
sleep(0.05)
if psm.isKeyPressed(): # if the GO button is pressed
psm.screen.clearScreen()
psm.screen.termPrintln("Exiting to menu")
psm.led(1,0,0,0)
psm.BAM1.float()
psm.BAM2.float()
psm.BBM1.float()
psm.BBM2.float()
sleep(0.1)
exit = True
示例3: ramp
# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import led [as 别名]
psm.BBM2.float()
if __name__ == '__main__':
psm.BAM1.resetPos()
ramp(RAMP_UP)
while not psm.isKeyPressed():
psm.screen.termPrintln('waiting')
psm.screen.clearScreen()
psm.screen.termPrintln('starting!')
for i in xrange(5):
psm.led(1, 255, 0, 0)
sleep(0.8)
psm.led(1, 0, 0, 0)
sleep(0.2)
psm.screen.clearScreen()
ramp(RAMP_MID)
sleep(0.5)
Thread(target = go).start()
while not exit:
sleep(0.05)
if psm.isKeyPressed():
psm.screen.clearScreen()
示例4: EV3Lights
# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import led [as 别名]
#starts an instance of PiStorms
ev3l = EV3Lights()
psm = PiStorms()
#exit variable will be used later to exit the program and return to PiStormsMaster
doExit = False
psm.screen.termPrintln("EV3Lights Demo")
psm.screen.termPrintln("connect mindsensors.com's ")
psm.screen.termPrintln("EV3Lights to BAS1 sensor Port")
psm.screen.termPrintln("")
psm.screen.termPrintln("")
psm.screen.termPrintln("")
psm.screen.termPrintln("")
psm.screen.termPrintln("Press GO button to exit")
psm.led(1, 0,0,0)
psm.led(2, 0,0,0)
psm.BAS1.activateCustomSensorI2C() #Connect the I2C sensor on the port BBS1
time.sleep(.1)
#main loop
# This test program will print IMU data on Terminal
# Compass heading is represented on Red LED on BANKB
# Program will exit when someone touch the screen or Go Button
time_gap = 0.5
while(not doExit):
#
try:
psm.led(1, 100,0,0)
示例5: PiStorms
# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import led [as 别名]
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0,parentdir)
#starts an instance of PiStorms
imu=ABSIMU()
psm = PiStorms()
#exit variable will be used later to exit the program and return to PiStormsMaster
doExit = False
psm.screen.termPrintln("AbsIMU test")
psm.screen.termPrintln("connect mindsensors.com's ")
psm.screen.termPrintln("AbsImu to BAS1 sensor Port")
psm.led(1, 0,0,0)
psm.led(2, 0,0,0)
psm.BAS1.activateCustomSensorI2C() #Connect the I2C sensor on the port BBS1
time.sleep(.1)
#main loop
# This test program will print IMU data on Terminal
# Compass heading is represented on Red LED on BANKB
# Program will exit when someone touch the screen or Go Button
while(not doExit):
#
try:
heading = imu.get_heading()
accl = imu.get_accelall()
mag = imu.get_magall()
示例6: PiStorms
# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import led [as 别名]
#please support mindsensors.com by purchasing products from mindsensors.com!
#Learn more product option visit us @ http://www.mindsensors.com/
# Tic Tac Toe
import random
import os,sys,inspect,time,thread
import socket,fcntl,struct
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0,parentdir)
from PiStorms import PiStorms
psm = PiStorms()
psm.led(1,0,0,0)
psm.led(2,0,0,0)
def drawLines():
#210x210, 55px side border, 15px vertical border, 70px squares
psm.screen.fillRect(124,15, 2,210)
psm.screen.fillRect(196,15, 2,210)
psm.screen.fillRect(55,84, 210,2)
psm.screen.fillRect(55,154, 210,2)
def drawBoard(board):
# This function prints out the board that it was passed.
# "board" is a list of 10 strings representing the board (ignore index 0)
k = { 'X': {
示例7: not
# 需要导入模块: from PiStorms import PiStorms [as 别名]
# 或者: from PiStorms.PiStorms import led [as 别名]
ev3ultrasonic_BBS1 = LegoDevices.EV3UltrasonicSensor("BBS1")
psm.screen.drawDisplay('Sensor Demo', True)
psm.screen.termPrintln('NXT Touch Sensor at BAS1')
psm.screen.termPrintln('EV3 Touch Sensor at BAS2')
psm.screen.termPrintln('EV3 Ultrasonic Sensor at BBS1')
time.sleep(1)
# This section requires two touch sensors. Connect them to Bank 1
# and press one by one to turn LED green. If they are both pressed at
# the same time, the LED will turn purple and the program will stop.
while not (nxttouch_BAS1.isPressed() and ev3touch_BAS2.isPressed()):
if nxttouch_BAS1.isPressed():
psm.led(1, 51, 255, 51)
else:
psm.led(1, 255, 0, 0)
if ev3touch_BAS2.isPressed():
psm.led(2, 51, 255, 51)
else:
psm.led(2, 255, 0, 0)
time.sleep(0.1)
psm.led(1, 102, 0, 204)
psm.led(2, 102, 0, 204)
time.sleep(2)
psm.led(1, 0, 0, 0)
psm.led(2, 0, 0, 0)
# Scans the distance 5 times
psm.screen.termPrintln('Starting distance sensor')