Skip to content

Instantly share code, notes, and snippets.

View Xayer's full-sized avatar
👨‍💻
Coding

Frederik Rabøl Xayer

👨‍💻
Coding
View GitHub Profile
{
"tankSize": 50,
"name": "Toyota Corolla T-Sport"
}
{"name":"Debugging of new Widgets","widgets":[{"type":"TodoList","title":"Todo List","settings":{"todos":[]},"w":1,"h":2,"y":0,"x":0,"i":1637132303640,"guid":1637132303640,"moved":false},{"type":"PriceRunnerProductInfo","title":"PriceRunner Price","settings":{"country":"dk","productId":"5182343","name":"Canon EOS R"},"w":1,"h":1,"maxH":1,"y":3,"x":0,"i":1639685400928,"guid":1639685400928,"moved":false},{"type":"PriceRunnerProductInfo","title":"PriceRunner Price","settings":{"country":"dk","productId":"3200433833","name":"Sony A7 IV"},"w":1,"h":1,"maxH":1,"y":4,"x":0,"i":1639685407228,"guid":1639685407228,"moved":false},{"type":"TextWidget","title":"Text","settings":{"message":"Stocks 📈"},"w":1,"h":1,"y":0,"x":1,"i":1639685490469,"guid":1639685490469,"moved":false},{"type":"TextWidget","title":"Text","settings":{"message":"Weather 🌧"},"w":2,"h":1,"y":0,"x":4,"i":1639685553815,"guid":1639685553815,"moved":false},{"type":"TextWidget","title":"Text","settings":{"message":"PriceRunner 📉"},"w":1,"h":1,"y":2,"x":0,"
from pybricks.hubs import CityHub
from pybricks.pupdevices import DCMotor, Light, ColorDistanceSensor, PFMotor
from pybricks.parameters import Button, Color, Direction, Port, Side, Stop
from pybricks.robotics import DriveBase
from pybricks.tools import wait, StopWatch
# Initialize the hub.
hub = CityHub()
trainMotor = DCMotor(Port.B, Direction.CLOCKWISE)
# Initialize the sensor.
@Xayer
Xayer / AdaptibleSpeedLGauge.py
Last active November 4, 2024 13:43
Pybricks algorithm for consistent train speed
# good introduction video to "Pybricks":
# https://www.youtube.com/watch?v=Jmh4NLxJ_8c
from pybricks.pupdevices import DCMotor, ColorDistanceSensor
from pybricks.hubs import CityHub
from pybricks.tools import StopWatch
from pybricks.parameters import Port, Color
# Initialize the motor and the sensor.
motor = DCMotor(Port.B)
sensor = ColorDistanceSensor(Port.A)