Getting started
from sense_hat import SenseHat
sense = SenseHat()
sense.show_message("Hello!")
LED matrix
set_pixel(x, y, r, g, b) · get_pixel(x, y) · set_pixels(list64) · get_pixels() · clear(r, g, b) · show_message(text, scroll_speed=0.1, text_colour=[255,255,255], back_colour=[0,0,0]) · show_letter(ch, ...) · set_rotation(0|90|180|270) · flip_h() · flip_v() · low_light · gamma / gamma_reset()
Sensors
get_temperature() · get_temperature_from_pressure() · get_humidity() · get_pressure() — driven by the sliders, with optional noise and drift like the real sensors.
Motion (IMU)
get_orientation() · get_orientation_radians() · get_accelerometer_raw() · get_gyroscope_raw() · get_compass() · get_compass_raw() · set_imu_config(c, g, a) — driven by yaw / pitch / roll.
Joystick
sense.stick.wait_for_event() · get_events() · callbacks via sense.stick.direction_up = my_function. Constants: DIRECTION_UP/DOWN/LEFT/RIGHT/MIDDLE, ACTION_PRESSED/RELEASED/HELD. Use the arrow keys + Enter (click the hardware panel first) or the on-screen pad.
Python
Python 3 (Skulpt — the same engine trinket uses). input() prompts in the console.
Working modules: math, random, time, re, string, itertools, functools, operator,
collections, datetime, bisect, copy, json, numpy, matplotlib.pyplot, turtle.
import sense_emu is an alias of sense_hat.
Graphs and graphics
import matplotlib.pyplot as plt
plt.bar(["Mon", "Tue", "Wed"], [4, 7, 5])
plt.title("Readings")
plt.grid(True)
plt.show()
Plots and turtle drawings render in the Output tab.
plot · scatter · bar · barh · hist · pie · legend · grid · xlabel · ylabel ·
xlim · ylim · xticks · axhline · figure(figsize=…).
import numpy as np
x = np.linspace(0, 6.28, 50)
print(np.mean(np.sin(x)).round(3))
array · arange · linspace · zeros · ones · eye · reshape · T · dot ·
sum · mean · std · median · sqrt · sin · cos · histogram · where · clip ·
random.seed/rand/randint/normal/choice/shuffle, plus boolean masking
(a[a > 3]) and 2-D indexing.
Not available offline
pygame and tkinter cannot run here. trinket ran both in
server-side containers, never in the browser — there is no single-file offline route to
either. For animation and graphics, use turtle or the Sense HAT LED matrix.
Shortcuts
Ctrl+Enter — run · Esc — stop · Tab / Shift+Tab — indent · arrows/Enter — joystick
(when the hardware panel has focus)
Offline
Single file, no CDN, runs from file:// or GitHub Pages. Code autosaves in your browser.