Approved content
The content below is provided by a partner.
• 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:
This repository can be added as an extension in MakeCode.
To edit this repository in MakeCode.
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()
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().
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();
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();
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:
durationMs / 4 (rounded down), since samples are collected every 4 ms.durationMs is larger than what the buffer contains, the function just returns the available samples.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();
spikerbit=github:BackyardBrains/pxt-spikerbit#v1.0.6