Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/boblio-max/origin/llms.txt

Use this file to discover all available pages before exploring further.

Origin makes GPIO output control a first-class language statement. Rather than importing a library, calling GPIO.setmode, and managing GPIO.setup yourself, you write a single line — set pin <n>, <state> — and Origin’s runtime handles the rest. This keeps hardware scripts readable and focused on intent, not infrastructure.

Syntax

set pin <n>, <state>
  • n — the BCM GPIO pin number (integer)
  • state1 to drive the pin HIGH, 0 to drive it LOW
The set pin command maps directly to the _execute_set_pin(n, state) runtime helper, which calls RPi.GPIO.output after configuring the pin as an output in BCM mode. You never call GPIO.setup or GPIO.setmode manually.

Basic Examples

Drive BCM pin 12 HIGH (for example, to illuminate an LED or enable a relay):
set pin 12, 1
Drive BCM pin 12 LOW (turn off the LED or deactivate the relay):
set pin 12, 0

BCM vs BOARD Numbering

Origin always uses BCM (Broadcom) numbering. BCM numbers refer to the GPIO signal line on the Broadcom SoC — they are the numbers printed in pink on most Raspberry Pi pinout diagrams. They are not the physical connector pin numbers (1–40).
BCMPhysical PinCommon Use
17Pin 11General purpose
18Pin 12PWM0 / general
27Pin 13General purpose
22Pin 15General purpose
12Pin 32PWM0
When wiring your circuit, identify the BCM number from a Pi pinout reference (such as pinout.xyz) and use that number directly in your Origin set pin statement.

Full Example: Blinking an LED

This script blinks an LED connected to BCM pin 17 ten times, with a half-second on and half-second off delay between each cycle.
import time

let pin_num: int = 17
let count: int = 0

while count < 10 {
    set pin pin_num, 1
    time.sleep(0.5)
    set pin pin_num, 0
    time.sleep(0.5)
    count += 1
}

print "Blink sequence complete."
1

Connect your LED

Wire the long leg (anode) of the LED through a 330 Ω resistor to BCM pin 17 (physical pin 11). Connect the short leg (cathode) to a GND pin (physical pin 6 or 14).
2

Save as blink.or

Save the script above as blink.or on your Raspberry Pi.
3

Run the script

Execute it with origin blink.or. The LED should blink ten times and then stop.

Toggling Multiple Pins

You can control multiple GPIO pins in the same script by calling set pin with different pin numbers:
import time

set pin 17, 1
set pin 27, 0
time.sleep(1)
set pin 17, 0
set pin 27, 1
time.sleep(1)
set pin 17, 0
set pin 27, 0
Each set pin call is independent — there is no shared state between different pin numbers.

Using a Variable for the Pin Number

The channel argument to set pin can be any expression that evaluates to an integer, including a variable:
let red_led: int = 17
let green_led: int = 27

set pin red_led, 1
set pin green_led, 0

Iterating Over Multiple Pins

Use a for loop with range() to iterate over a sequence of pin numbers:
import time

for i in range(0, 5) {
    set pin 17, 1
    time.sleep(0.1)
    set pin 17, 0
    time.sleep(0.1)
}

print "Flash complete."
set pin requires the RPi.GPIO Python library. Install it on your Raspberry Pi with pip install RPi.GPIO. On a non-Pi host, the runtime prints a simulation message — for example, [SIM] Pin 17 set to 1 — instead of driving real hardware. This is useful for verifying script logic before deployment.
Never connect an LED directly between a GPIO pin and ground without a current-limiting resistor. A Raspberry Pi GPIO pin sources approximately 16 mA maximum; exceeding this can permanently damage the SoC. Always use a 220 Ω–470 Ω resistor in series with the LED anode. For inductive loads such as motors or relays, use an appropriate driver circuit — do not drive them directly from GPIO.

Build docs developers (and LLMs) love