Sensors & Inputs Matrix
Sensors enable your virtual projects to perceive environmental stimuli. Intarva simulates real-world physics to provide accurate data streams for your logic.
The Physics of Perception
In the Intarva engine, sensors are divided into two primary categories based on how they report data:
Digital Inputs (State-Based)
Binary triggers like buttons and PIR sensors. Intarva simulates Contact Bounce (electromechanical noise) to ensure your debouncing code is production-ready.
Analog Inputs (Continuum)
Variable signals like light (LDR) or sound. These rely on Voltage Dividers—the sensor varies its resistance, which the ADC converts into a numeric value between 0 and 65535.
Time-of-Flight (ToF): Our Ultrasonic sensors calculate the microsecond delay between a trigger pulse and its echo off a virtual obstacle, accurately reflecting the speed of sound (343 m/s).
Technical Matrix
| Sensor | Sensing Principle | Implementation Snippet |
|---|---|---|
| Tactile Button | Digital switch with pull-up/down capability. Simulates mechanical bounce. |
new Button('GP14').on('press', callback);Pin(14, Pin.IN, Pin.PULL_DOWN).value() |
| LDR (Light) | Photo-resistor. Higher light levels reduce resistance, increasing the ADC voltage. |
new ADC('GP26').read(); // 0 to 65535ADC(Pin(26)).read_u16() |
| HC-SR04 (Distance) | Acoustic ranging. Measures time-of-flight for sound waves to calculate distance. |
new Distance('GP4', 'GP5').read(); // cm# Pulse trigger and time echo... |
| Accelerometer | 3-axis tilt and g-force sensing. Ideal for tracking orientation changes. |
new Accel().on('change', (x,y,z) => {});# Read via I2C registers... |
| Potentiometer | Variable voltage divider. Allows for manual analog input through a rotary dial. |
new ADC('GP27').read();ADC(Pin(27)).read_u16() |