Walk through real Origin programs — from hello world to hardware control.
Origin scripts use the .or extension. Save this as hello.or:
print "Hello, World!"
Run it:
print is a statement in Origin, not a function — no parentheses needed. Strings can use double or single quotes.
Every variable needs a type annotation. Origin checks types at compile time and won't let you assign mismatched values:
let name: str = "Origin"
let year: int = 2026
let pi: float = 3.14159
let ok: bool = true
Constants use const and can't be reassigned:
const app_name: str = "Origin"
# app_name = "Something else" ← compile error
Origin supports standard arithmetic. Here's a calculator that reads user input:
print "WELCOME TO THE CALCULATOR"
let x: float = float(input "Enter a number: ")
let y: float = float(input "Enter another number: ")
let op: str = input "Enter the operation (+, -, *, /): "
print "Your result is..."
if op == "+" {
print x + y
} elif op == "-" {
print x - y
} elif op == "*" {
print x * y
} elif op == "/" {
print x / y
}
input reads a line of text. float() casts the string to a number. Type casting uses postfix syntax — float(input "...") chains naturally left to right.
Origin's if / elif / else works like you'd expect. Conditions don't need parentheses:
let temp: int = 75
if temp > 80 {
print "Too hot"
} elif temp > 60 {
print "Just right"
} else {
print "Too cold"
}
Use loop for counted iteration and while for condition-based:
loop 5:
print "Iteration"
let count: int = 0
while count < 3 {
print count
count = count + 1
}
Functions are defined with def and must declare their return type after ->:
def add(a: int, b: int) -> int {
return a + b
}
def greet(name: str) -> none {
print "Hello, " + name
}
let result: int = add(5, 3)
print result
greet("Origin")
Origin's hardware syntax is the main reason it exists. On a Raspberry Pi with a servo on channel 0 of a PCA9685 driver:
set servo.angle 0, 90
wait 1
set servo.angle 0, 180
wait 1
set servo.angle 0, 0
The servo angle is automatically clamped to 0-180° — if you try to set 200, Origin silently caps it to 180. This prevents physical gear damage.
wait pauses execution in seconds (accepts floats like 0.5).
Drive a BCM pin high or low:
set pin 17, 1 # HIGH
wait 0.5
set pin 17, 0 # LOW
When hardware isn't available (e.g., on a laptop), Origin falls back to [SIM] stubs — the same code runs without modification.
Use py {} blocks to drop into Python for anything Origin doesn't handle natively:
py {
import math
import os
print("Python process ID:", os.getpid())
print("Sine of 90 degrees:", math.sin(math.pi / 2))
}
Variables defined in py {} blocks are accessible from Origin code after the block exits, so you can use Python libraries and pass results back to Origin.
Origin ships with calc.or and graph.or in lib/. Import them by name:
import calc
import graph
calc = calc()
print calc.sqrt(25)
print calc.pi
graph "Sine Wave" with {
X: color(0, 0, 1) as "Line 1",
}
Libraries are just .or files. You can write your own and put them next to your script — import mylib will pick them up automatically.
Compile any .or script into a standalone executable with build:
The output is a zero-dependency executable — no Python or Origin install needed on the target machine.