Uniot Docs
  • Introduction
  • Guides
    • Getting Started
    • Uniot Badge
    • Device Network
  • Foundations
    • Edge Logic Deployment
  • General Concepts
    • Primitives
    • Scripting
  • Platform
    • Dashboard
    • Sandbox
      • Visual Editor
        • Special
        • Logic
        • Math
        • Loops
        • Text
        • Variables
        • Functions
        • Primitives
      • Logger
      • Emulator
      • Control Panel
  • Advanced
    • Uniot Core
      • Scheduler
        • TaskScheduler
        • IExecutor
        • ISchedulerConnectionKit
        • Task
        • SchedulerTask
      • AppKit
        • AppKit
        • LispDevice
        • LispPrimitives
        • TopDevice
      • CBORWrapper
        • CBORObject
        • COSE
        • COSEMessage
        • ICOSESigner
      • Date
        • Date
        • SimpleNTP
      • EventBus
        • EventBus
        • IEventBusConnectionKit
        • DataChannels
        • EventEmitter
        • EventListener
        • EventEntity
        • CallbackEventListener
      • Hardware
        • Button
      • LispWrapper
        • DefaultPrimitives
        • LispHelper
        • PrimitiveExpeditor
        • unLisp
      • MQTTWrapper
        • CallbackMQTTDevice
        • MQTTDevice
        • MQTTKit
        • MQTTPath
      • Network
        • ConfigCaptivePortal
        • NetworkController
        • NetworkScheduler
      • Register
        • GpioRegister
        • ObjectRegister
        • ObjectRegisterRecord
        • Register
        • RegisterManager
        • RegisterManagerProxy
      • Storage
        • CBORStorage
        • CrashStorage
        • Storage
        • WifiStorage
      • Utils
        • Array
        • Bytes
        • ClearQueue
        • IterableQueue
        • LimitedQueue
        • GlobalBufferMemoryManager
        • Map
        • Singleton
        • TypeId
      • Credentials
    • Uniot Lisp
      • Language Description
      • Embedding Instructions
  • API
    • MQTT Convention
Powered by GitBook
On this page
  • analog read
  • analog write
  • digital read
  • digital write
  • button clicked
  • user primitive (template)
  • user primitive (autogenerated)
  1. Platform
  2. Sandbox
  3. Visual Editor

Primitives

PreviousFunctionsNextLogger

Last updated 2 months ago

Primitives provide direct access to your device's hardware capabilities. These fundamental blocks enable you to:

  • Read sensor values

  • Control digital outputs

  • Manage analog signals

  • Create custom hardware interactions

When using primitives, you'll work with indices rather than direct pin numbers. The register system organizes pins into categories (digital input/output, analog input/output) and assigns each pin an index. You can view the mapping between physical pins and register indices in your device's Registers tab on the Uniot Platform.

analog read

Reads an analog value from a specified pin (range: 0-1023).

Parameters:

  • Pin (Number): The analog pin to read from

Returns:

  • Number: Value between 0-1023

Example:

analog write

Sets an analog (PWM) value on a pin (range: 0-1023).

Parameters:

  • Pin (Number): The PWM-capable pin

  • Value (Number): Value between 0-1023

Example:

digital read

Reads a digital value from a pin (HIGH or LOW).

Parameters:

  • Pin (Number): The digital pin to read from

Returns:

  • Boolean: #t for high, () for low

Example:

digital write

Sets a digital pin to high or low.

Parameters:

  • Pin (Number): The digital pin

  • Value (Boolean): #t for high, () for low

Example:

button clicked

Checks if a button on a specified pin was clicked since the last check.

Parameters:

  • Pin (Number): The digital pin

Returns:

  • Boolean: #t if the button was clicked, () otherwise

Example:

user primitive (template)

A template for defining custom primitives with configurable parameters and return values. The user primitive returns a boolean value by default. If you need to perform only some actions and do not expect any data in response, you need to customize the block by clicking on the gear icon.

Parameters:

  • Parameters (As defined by the user)

Returns:

  • Any type (As defined by the user)

user primitive (autogenerated)

Accesses custom primitives defined in firmware. The primitive returns a boolean value by default. If you need to perform only some actions and do not expect any data in response, you need to customize the block by clicking on the gear icon.

Parameters:

  • Parameters (As defined by the user)

Returns:

  • Any type (As defined by the user)

Example:

register
Check light level and push event if it's too low.
Receives brightness value from the dashboard (or another device) and sets it to the LED.
Read switch state and push event when it is changed.
Checks if an event was received and sets the LED accordingly.
Checks if a button was clicked, change the state, and sets the LED accordingly.
Custom LED strip control