Primitives
Last updated
Last updated
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 register 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.
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:
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:
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:
Sets a digital pin to high or low.
Parameters:
Pin (Number): The digital pin
Value (Boolean): #t
for high, ()
for low
Example:
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:
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)
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: