Editor modes
SAM Script offers three editing modes. Each mode is suited to a different level of experience or workflow.Blocks
Drag and drop visual blocks to build your program. A live code preview shows the equivalent JavaScript as you work — a great way to learn how code maps to visual logic.
JavaScript
Write JavaScript directly in a text editor. Full access to the SAM object API, async/await patterns, loops, and conditions. Ideal for students comfortable with text-based coding.
Python
Write Python in a clean text editor. Uses the
sam module with snake_case methods. A natural fit if you already know Python from school or other projects.Switching modes
The mode toggle sits at the top of the editor. Click Blocks, JavaScript, or Python to switch.Switching from Blocks to JavaScript or Python converts your visual program into code automatically. Switching back from code to Blocks may not always be possible if your code contains patterns the Blocks editor cannot represent — SAM Studio will warn you before any work is lost.
The toolbar
The toolbar runs along the top of the editor and gives you quick access to the most important actions:| Button | What it does |
|---|---|
| Run | Uploads and executes your program on the connected SAM hardware. |
| Stop | Halts the currently running program. |
| Save | Saves the project to your local storage. |
The block palette
In Blocks mode, the panel on the left side of the screen is the block palette. It organises available blocks into categories:- Hardware — blocks for your connected SAM devices (LEDs, motors, buttons, sensors, and more)
- Control Flow — if/else branches, wait blocks, and program start triggers
- Variables — create and update named values in your program
- Logic — comparisons and boolean operators (AND, OR, NOT)
- Loops — repeat, while, and for-each structures
The canvas and code area
The large panel on the right is where you build or write your program:- In Blocks mode, this is the canvas — a free-form workspace where you connect blocks together.
- In JavaScript or Python mode, this is a text editor with syntax highlighting, line numbers, and basic autocomplete for SAM APIs.
Console output
The Console panel sits at the bottom of the editor. It displays:- Output from
console.log()(JavaScript) orprint()(Python) calls in your program - Runtime errors and connection messages
- Confirmation messages when your program starts and stops
Creating your first SAM Script project
Select SAM Script
In the project type picker, choose SAM Script. This opens the script editor rather than the flow-based canvas.
Give the project a name
Type a name for your project in the dialog that appears, then click Create. Choose something descriptive — you can always rename it later.
Choose your mode
At the top of the editor, select the mode you want to start in: Blocks, JavaScript, or Python. Not sure which to pick? Start with Blocks and switch to code when you feel ready.
Connect your hardware
Make sure your SAM Labs blocks are powered on and in range. SAM Studio will detect them automatically. You’ll see connected blocks listed in the Hardware section of the block palette (Blocks mode) or available via the
SAM.connect() / sam.connect() API (code modes).