Skip to content

Instantly share code, notes, and snippets.

View ViewController.swift
// ViewController.swift
// WebSocketInjection
// Created by Shinichiro Oba on 2021/03/18.
import UIKit
import WebKit
bricklife /
Last active Jul 4, 2020
Autonomous running train in Pybricks
from pybricks.hubs import CityHub
from pybricks.pupdevices import DCMotor, ColorDistanceSensor
from pybricks.parameters import Port, Color
from import wait
hub = CityHub()
motor = DCMotor(Port.A)
color_sensor = ColorDistanceSensor(Port.B)
def wait_for_color(color):
bricklife / LEGO SPIKE Prime JSON command
Last active Jan 11, 2021
LEGO SPIKE Prime JSON command examples
View LEGO SPIKE Prime JSON command


{"m":"program_modechange","p":{"mode":"play"}} // "mode": "play" or "download"
{"i":"ESGe","m":"set_hub_name","p":{"name":"U1BJS0U="}} // "name": Base64 string


View ESP32-1Button-BLE-Keyboard.ino
#include <BleKeyboard.h> //
BleKeyboard bleKeyboard;
bool pressing = false;
void setup() {
pinMode(25, INPUT_PULLUP); // A1 pin
View Digispark-1Button-Keyboard.ino
#include "DigiKeyboard.h"
bool pressing = false;
void setup() {
pinMode(0, INPUT);
digitalWrite(0, HIGH); // Pull Up
void loop() {
View Teensyduino-1Button-Keyboard.ino
#include <Bounce.h>
Bounce button = Bounce(1, 10);
void setup() {
pinMode(1, INPUT_PULLUP);
void loop() {
bricklife /
Created May 21, 2020
Send command to SPIKE from EV3
#!/usr/bin/env pybricks-micropython
from pybricks.hubs import EV3Brick
from import wait
from pybricks.parameters import Button
from connection import SpikePrimeStreamReader
# Add send_command method into SpikePrimeStreamReader class
def send_command(self, command):
self.sock.send((command + '\r').encode())
bricklife / SPIKE_Prime_REPL.txt
Last active Jan 16, 2020
REPL mode on LEGO Education SPIKE Prime hub
View SPIKE_Prime_REPL.txt
MicroPython v1.9.4-1146-gca9944357 on 2019-10-03; LEGO Technic Large Hub with STM32F413xx
Type "help()" for more information.
>>> help()
Welcome to MicroPython!
For online help please visit
Quick overview of commands for the board: -- print some general information
hub.status() -- print sensor data
bricklife /
Last active Jan 16, 2020 in LEGO Education SPIKE Prime Hub
import gc
import micropython
import hub_runtime
bricklife /
Last active Jan 16, 2020
Overwriting in LEGO Education SPIKE Prime Hub
import io
f ='', 'w')
import hub
import time
while True:'00000:00000:00900:00000:00000:'))