PybricksHub test in JS
connect
disconnect
REPL
send
clear
import { PrimeHub } from "pybricks/hubs.js"; import { Motor, ColorSensor, UltrasonicSensor, ForceSensor } from "pybricks/pupdevices.js"; import { Button, Color, Direction, Port, Side, Stop } from "pybricks/parameters.js"; import { DriveBase } from "pybricks/robotics.js"; import { wait, StopWatch } from "pybricks/tools.js"; import { Matrix } from "pybricks/geometry.js"; import { randint } from "urandom.js"; const hub = PrimeHub(); const X = 100; const field = [ [0, X, 0, 0, 0], [0, 0, 0, X, X], [0, X, 0, X, 0], [0, X, 0, 0, X], [X, X, 0, X, X], ]; hub.display.icon(field) const m1 = Motor(Port.A); const m2 = Motor(Port.B); function forward(n) { print("forward"); m1.run(n); m2.run(-n); } function right(n) { print("right"); m1.run(n); m2.stop(); } function left(n) { print("left"); m2.stop(); m1.run(-n); } for (;;) { forward(300); wait(500); right(300); wait(500); left(300); wait(1000); }
set program
start program
stop program
docs:
Pybricks Documentation — pybricks v3.2.0 documentation
fimware:
install Pybrics firmawre
lib:
JS2Py
src on GitHub
(forked from
pybricks-code
in
Pybricks
)