SAM Script is currently in beta. Some features may change as we continue to improve the experience. We’d love your feedback — use the feedback button inside SAM Studio to share your thoughts.
Blocks View and Code View
SAM Script gives you two ways to work in the same project:- Blocks View
- Code View
The Blocks view shows a visual representation of your program using labelled blocks — similar to SAM Blockly. Use it to sketch out your logic quickly or to help newer coders follow along with what the program does.
Creating a SAM Script Project
Select SAM Script
Choose SAM Script from the environment picker. The code editor opens with a starter file.
Choose your language
In the top bar, select either JavaScript or Python from the language dropdown. You can switch languages at any time — your code will be converted automatically where possible.
Pair your hardware
Click Connect and follow the Bluetooth pairing prompts to link your SAM Labs blocks. Physical hardware is recommended for SAM Script, as it gives students immediate, tangible feedback.
Write your program
Type your code in the editor. Use the SAM API to read sensor values and control output blocks (see the examples below).
Code Examples
Here are two equivalent programs that blink an LED on and off every second — one in JavaScript and one in Python.- JavaScript
- Python
SAM.connect('led')finds and pairs the LED block over Bluetooth.led.setColor(r, g, b)sets the colour using red, green, and blue values from 0–255.SAM.wait(1000)pauses execution for 1000 milliseconds (one second).- The
while (true)loop repeats the blink indefinitely until you press Stop.
Key Features
Real languages
Students write genuine JavaScript or Python — the same languages used by professional developers. Skills transfer directly beyond the classroom.
Two-way Blocks ↔ Code sync
Switch between Blocks view and Code view at any time. Changes in one view are reflected in the other, making the transition from visual to text-based coding seamless.
Physical hardware first
SAM Script is optimised for use with real SAM Labs blocks connected over Bluetooth, giving students tactile, real-world feedback for their code.
Full SAM API access
Unlock the complete SAM Labs hardware API — read raw sensor data, chain multiple blocks, set precise timing, and build logic that goes far beyond what block-based environments support.
Saving Your Work
Get into the habit of saving before you run, before you switch views, and before you leave your seat. It’s a great real-world practice that mirrors professional software development workflows.Who Should Use SAM Script?
SAM Script is best suited for:- Grades 7 and up who have already completed projects in SAM Blockly.
- After-school coding clubs working on advanced STEAM challenges.
- Teachers who want to introduce a real programming language alongside physical computing.
- Students preparing for AP Computer Science or other programming courses who want hands-on hardware experience.