GPIO Basics
General Purpose Input/Output (GPIO) pins are the primary interface between your code and the physical (or virtual) world.
1. Digital Logic States
In the Intarva simulation, every GPIO pin operates on a Binary Logic system. There are only two stable states:
HIGH (1)
Represents the source voltage (typically 3.3V on a Pico). In code, this is True or 1.
LOW (0)
Represents Ground (0V). In code, this is False or 0.
2. Pin Modes (Dual Language)
Before you can use a pin, you must define its direction. In Intarva, you can control pins using either firmware-level Python or high-level JavaScript orchestration.
Writing to an OUTPUT Pin
import { Pin } from 'intarva';
const led = new Pin('GP25');
led.write(1); // Set HIGH
from machine import Pin
led = Pin(25, Pin.OUT)
led.value(1) # Set HIGH
Reading from an INPUT Pin
import { Pin } from 'intarva';
const button = new Pin('GP14');
const state = button.read(); // Returns 0 or 1
from machine import Pin
button = Pin(14, Pin.IN)
state = button.value() # Returns 0 or 1
3. High-Impedance & Floating Pins
When a pin is set to Pin.IN, it enters a high-impedance state. It acts like a very sensitive antenna. If nothing is connected to it, the simulator might show an “X” (Floating) state because the voltage is undefined.
Pin.PULL_UP or Pin.PULL_DOWN in your code if your physical button doesn’t have an external resistor. This ensures a deterministic LOW or HIGH state when the button is open.