class BreakOutOfALoop(Exception): pass class ContinueLoop(Exception): pass _brickConfiguration = { 'wheel-diameter': 5.6, 'track-width': 18.0, 'actors': {}, 'sensors': { '1': Hal.makeTouchSensor(ev3dev.INPUT_1), '2': Hal.makeGyroSensor(ev3dev.INPUT_2), '3': Hal.makeColorSensor(ev3dev.INPUT_3), '4': Hal.makeUltrasonicSensor(ev3dev.INPUT_4), }, } hal = Hal(_brickConfiguration) def run(): while True: if (0 == 0) and True: break hal.waitFor(15) hal.waitFor(500) while True: if hal.isPressed('1') == True: break
from roberta.ev3 import Hal from roberta.BlocklyMethods import BlocklyMethods from ev3dev import ev3 as ev3dev import math import traceback _brickConfiguration = { 'wheel-diameter': 5.6, 'track-width': 18.0, 'actors': { 'RIGHT':Hal.makeLargeMotor(ev3dev.OUTPUT_A, 'on', 'foreward', 'right'), 'LEFT':Hal.makeLargeMotor(ev3dev.OUTPUT_D, 'on', 'foreward', 'left'), }, 'sensors': { 'color': Hal.makeColorSensor(ev3dev.INPUT_2), # 'distance': Hal.makeUltrasonicSensor(ev3dev.INPUT_2), 'touchLeft': Hal.makeTouchSensor(ev3dev.INPUT_4), 'touchRight': Hal.makeTouchSensor(ev3dev.INPUT_1), }, } hal = Hal(_brickConfiguration) def rotate(direction): hal.rotateDirectionAngle('LEFT', 'RIGHT', False, direction, 20, 80) angle = 5 right = False def followTheTape():