samplingPeriod = 0.005 waitSleep = 0.005 globalSpeed = 100 # Turn on logging olog = logging.getLogger('orion') if debugLevel == 'INFO': olog.setLevel(logging.INFO) elif debugLevel == 'DEBUG': olog.setLevel(logging.DEBUG) olog.addHandler(logging.StreamHandler(sys.stdout)) # Create a board orionBoard = orion() # Create sensors us_left = leftUltrasonicSensor() orionBoard.port8.addDevice(us_left) us_center = centerUltrasonicSensor() orionBoard.port3.addDevice(us_center) us_right = rightUltrasonicSensor() orionBoard.port4.addDevice(us_right) # Create actuators rightMotor = encodermotor(slot.SLOT_1) leftMotor = encodermotor(slot.SLOT_2) orionBoard.motor1.addDevice(rightMotor)
from config import slot import logging from orion import * import sys import time # Turn on logging olog = logging.getLogger('orion') olog.setLevel(logging.INFO) olog.addHandler(logging.StreamHandler(sys.stdout)) # Create a board orionBoard = orion() # Create some sensors to plug into the board tempSensor = temperatureSensor(slot.SLOT_1) sevSeg = sevenSegmentDisplay() # Add sensors to the ports they are connected to orionBoard.port4.addDevice(tempSensor) orionBoard.port3.addDevice(sevSeg) # Read the most recent temperature from the temp # sensor and display lastTemp = tempSensor.latestValue() while True: tempSensor.requestValue() curTemp = tempSensor.latestValue() if curTemp != lastTemp: sevSeg.setValue(curTemp)
import config from devices import * from orion import * from packets import responsepacket from testserial import * import time t = temperatureSensor(slot.SLOT_2) testport = testserial() board = orion(testport) board.port1.addDevice(t) testport.write(bytearray([255, 85, 33, 3, 0, 128, 174, 65, 13, 10])) latest = t.latestValue() while latest == -1: time.sleep(0.5) latest = t.latestValue() print latest