Approved content

The content below is provided by a partner.

BackyardBrains/pxt-spikerbit 1.0.6 GitHub

Spiker:Bit extension

MakeCode • EMG • EEG • ECG

This extension enables the use of the Backyard Brains Spiker:Bit with the Microsoft MakeCode editor. The Spiker:Bit records electrical activity from the brain (EEG), muscles (EMG), and heart (ECG), making neuroscience and physiology experiments accessible in educational settings. Use this extension to create interactive projects and explore real‑time bio‑signals in your classroom or lab. For more details about the Spiker:Bit please check our product page Backyard Brains Spiker:Bit.

Further learning and lesson ideas:

Use as Extension

This repository can be added as an extension in MakeCode.

Note for micro:bit V1 users: On micro:bit V1 boards, you may notice a slight glow on some LEDs. This is due to shared use of certain pins (e.g., pin P9) between the LED matrix and the Spiker:Bit. This visual effect is harmless and does not affect the functionality of the Spiker:Bit or the micro:bit.

Edit this project

To edit this repository in MakeCode.

Example

Here is the API with teacher‑friendly examples. You can copy these into MakeCode JavaScript editor.

Classroom example: show EMG envelope on the LEDs for 3 seconds, then stop.

spikerbit.startMuscleRecording()
loops.everyInterval(100, function () {
    let value = spikerbit.musclePowerSignal()
    let bar = Math.map(value, 0, 1023, 0, 25)
    led.plotBarGraph(bar, 25)
})
basic.pause(3000)
spikerbit.stopRecord()

API Functions

Muscle Group

startMuscleRecording()

Starts recording muscle (EMG) signals.

spikerbit.startMuscleRecording();

musclePowerSignal(): number

Returns the last envelope value of the EMG signal.

let power = spikerbit.musclePowerSignal();

// Raw EMG function is not exposed; use the envelope with musclePowerSignal().

Heart Group

startHeartRecording()

Starts recording heart (ECG) signals.

spikerbit.startHeartRecording();

heartSignal(): number

Returns the last measured ECG signal.

let signal = spikerbit.heartSignal();

heartRate(): number

Returns the calculated heart rate based on the last two heart beats.

let rate = spikerbit.heartRate();

Brain Group

startBrainRecording()

Starts recording brain (EEG) signals.

spikerbit.startBrainRecording();

brainSignal(): number

Returns the last measured EEG signal.

let signal = spikerbit.brainSignal();

brainAlphaPower(): number

Returns the alpha wave power of the EEG signal.

let alphaPower = spikerbit.brainAlphaPower();

Helper Utility

print(value: number): void

The print function sends a numeric value to the serial output with the label "Value".
This allows students and teachers to easily record or visualize data in MakeCode Data Logger or any serial monitoring tool.

You can use it to print measurements from any Spiker:Bit signal, such as the EMG envelope, raw ECG or EEG values, heart rate, or EEG alpha power.

spikerbit.print(spikerbit.heartRate());

signalBlock(): number[]

Returns a array of the raw recorded signal from the internal buffer, sampled at 250 Hz (one value every 4 ms).

Key behaviour:

let signalBlock = spikerbit.signalBlock();
let shortSignalBlock = spikerbit.signalBlock(500);

maxSignalInLast(durationMs: number): number

Returns max value of signal for the specified duration in milliseconds. For EMG it returns max of power (envelope) of the signal. For EEG and ECG it returns max of raw signal. Uses an internal buffer sampled at 250 Hz.

let maxDuringLastSecond = spikerbit.maxSignalInLast(950);

numPeaksInLast(durationMs: number): number

Returns the number of peaks in the signal for the specified duration in milliseconds.

let numPeaks = spikerbit.numPeaksInLast(950);

stopRecord()

Stop recording and clear internal buffers.

stopRecord();

Metadata (used for search, rendering)

spikerbit=github:BackyardBrains/pxt-spikerbit#v1.0.6